README.md

Travis-CI Build Status Coverage Status CRAN_Status_Badge Downloads

Rsync as R-Package

rsync is a open source file-copying tool that is freely available under the GNU General Public License. This is a R package providing an API to rsync from R.

Why use rsync:

Rsync is a tool, which is used with Unix systems and allows efficient transferring and synchronizing of files across systems. It is widely used for making backups, copying files or mirroring them.

Working with Rsync offers nice benefits, as it is: - fast - works remotly and locally - minimizes data transfer, as it only transfers the changes within the files - supports copying links, devices, owners, groups, and permissions

For further information about rsync, please visit https://rsync.samba.org/.

Similar and very popular alternatives exist. E.g. in contrast to AWS S3 the solution here:

Installation:

The rsync R package can be downloaded and installed by running the following command from the R console:

devtools::install_github("INWTlab/rsync")

Make sure you have the rsync command line tool available. Alternatively you can use the INWTLab drat repository by adding

options(repos = c(getOption("repos"), INWTLab = "https://inwtlab.github.io/drat/"))
install.packages("rsync")

to your configuration.

Examples

You create a rsync configuration using:

library(rsync)
dir.create("destination")
dir.create("source")
dest <- rsync(dest = "destination", src = "source")
dest
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/source/
##   dest: /home/lswarnholz/projects/rsync/destination/ 
## Directory in destination:
## [1] name         lastModified size        
## <0 Zeilen> (oder row.names mit Länge 0)

In the case of an rsync daemon you can also supply a password. The way you think about transactions is that we have a destination folder with which we want to interact. All methods provided by this package will always operate on the destination. It will not change the source, in most cases. An exception is sendObject, that will also create a file in source.

x <- 1
y <- 2
sendObject(dest, x)
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/source/
##   dest: /home/lswarnholz/projects/rsync/destination/ 
## Directory in destination:
##      name        lastModified size
## 1 x.Rdata 2021-09-06 22:15:38   70
sendObject(dest, y)
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/source/
##   dest: /home/lswarnholz/projects/rsync/destination/ 
## Directory in destination:
##      name        lastModified size
## 1 x.Rdata 2021-09-06 22:15:38   70
## 2 y.Rdata 2021-09-06 22:15:38   69

We can see that we have added two new files. These two files now exist in the source directory and the destination. The following examples illustrate the core features of the package:

removeAllFiles(dest) # will not change source
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/source/
##   dest: /home/lswarnholz/projects/rsync/destination/ 
## Directory in destination:
## [1] name         lastModified size        
## <0 Zeilen> (oder row.names mit Länge 0)
sendFile(dest, "x.Rdata") # so we can still send the files
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/source/
##   dest: /home/lswarnholz/projects/rsync/destination/ 
## Directory in destination:
##      name        lastModified size
## 1 x.Rdata 2021-09-06 22:15:38   70
removeAllFiles(src <- rsync("source")) # make the source a destination
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/
##   dest: /home/lswarnholz/projects/rsync/source/ 
## Directory in destination:
## [1] name         lastModified size        
## <0 Zeilen> (oder row.names mit Länge 0)
getFile(dest, "x.Rdata")
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/source/
##   dest: /home/lswarnholz/projects/rsync/destination/ 
## Directory in destination:
##      name        lastModified size
## 1 x.Rdata 2021-09-06 22:15:38   70
src
## Rsync server: 
##   src: /home/lswarnholz/projects/rsync/
##   dest: /home/lswarnholz/projects/rsync/source/ 
## Directory in destination:
##      name        lastModified size
## 1 x.Rdata 2021-09-06 22:15:38   70


INWTlab/rsync documentation built on Sept. 28, 2023, 5:22 p.m.