Tips&Tricks

Rsync basics. How to synchronize your files

Synchronization

Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon.

Basic example

rsync -avz ./src ./dest

Transfer options

-z, --compress
-n, --dry-run

Display options

-q, --quiet
-v, --verbose
-h, --human-readable
--progress

Skipping options

-u, --update     # skip files newer on dest
-c, --checksum   # skip based on checksum, not mod-time & size

Backup options

-b, --backup           # backup with suffix
--suffix=SUFFIX    # default ~ without --backup-dir
--backup-dir=DIR

Include options

--exclude=PATTERN
--include=PATTERN
--exclude-from=FILE
--include-from=FILE
--files-from=FILE    # read list of filenames from FILe

Archive options

-a, --archive    # archive (-rlptgoD)
-r, --recursive
-l, --links      # copy symlinks as links
-p, --perms      # preserve permissions
-t, --times      # preserve times
-g, --group      # preserve group
-o, --owner      # preserve owner
-D               # --devices --specials
--delete         # Delete extra files

Rsync is a powerful tool to synchronize your files. It’s very useful when you need to make a copy of some directory on remote server and be sure that your copy will be equals on the next update.

Just put rsync command into crontab and you have your own backup system!