Rsync tool is useful to efficiently synchronize files from a source to a destination. It does incremental synchronization by comparing the modification times and size of files.
The rsync
command is used to do the synchro.
Useful parameters:
-
-a
: recursive (recurse into directories), links (copy symlinks as symlinks), perms (preserve permissions), times (preserve modification times), group (preserve group), owner (preserve owner), preserve device files, and preserve special files. -
-v
: verbose -
-h
: shows numbers in human readable format -
--progress
: shows transfer progress -
--delete
: deletes files that aren’t anymore in source directory -
trailing slash on source directory: If there is a trailing slash on the source directory, the content of the directory will be synchronized. If not, the directory and it content will be synchronized. For example, the two comands below do the same:
rsync -av /src/foo /dest rsync -av /src/foo/ /dest/foo
Sync to other folder
Copy the content of SRC_DIR/
into DST_DIR
:
rsync -avh --delete SRC_DIR/ DST_DIR
Sync to other computer with ssh
Copy the content of SRC_DIR/
into DST_DIR
on an other host:
rsync -avh --delete -e ssh SRC_DIR/ USER@HOST:/DST_DIR
-e
: specify remote shell