sync: Sync files

Description Usage Arguments Details Note See Also Examples

View source: R/sync.R

Description

sync copies files from a to b, and from b to a. No deletions.

Usage

1
sync(a, b, exclude = "")

Arguments

a

path of one directory

b

path of a second directory

exclude

character vector of files or folders to exclude; paths are relative

Details

Uses 2 consecutive calls to rsync, switch the order of the path arguments between the 2 calls. First time copies files from a to b, second time it copies files from b to a. Specifically, the command is rsync -azuP --stats "a" "b", followed by rsync -azuP --stats "b" "a". The -a is arhive mode (recursive, most file attributes), -z enables compression, -u only moves files that are new or updated, and -P prints progress. --stats prints more information. No files are ever deleted. I.e., the directories end up containing the most up-to-date files in both directories, and files previously only contained in one directory are simply copied to the other.

Note

When syncing the contents of a directory, remember that it is important to include a forward slash (/) at the end of both paths a and b; omitting in the second will create an extra copy in the first. If slash omitted from both, the top level name will exist 3 times and include two replicates. This is just basic rsync syntax, but it is easy to forget.

See Also

Use mirror if the contents of a master directory should be copied to a backup directory, potentially deleting files in the backup that are not contained in the master. See rbLib-package for package overview.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
# I have a project in a folder called 'CyanoIso'
# I want two copies of this folder and its contents on my computer
a <- "Documents/School&Work/WiscResearch/CyanoIso/"
b <- "Dropbox/Cyanotopes/CyanoIso/" # omitting last slash creates extra copy
exclude <- c(".git", "Data")
(sync(a, b, exclude))

## End(Not run)

rBatt/rbLib documentation built on May 26, 2019, 7:45 p.m.