rsync - Easily Transfer and Synchronize Files Between Computers
rsync is a great utility that can be use for transferring files to and from a remote computer. It can be use to sync files between the computers as well.
rsync can be installed from the package manager on a Debian system:
sudo apt install rsync -y
The basic syntax for rsync is as follows:
rysnc -optional-flags soruce-file-location destination-file-location
One of the rsync command I prefer to use is the following:
#Sync file from source to destination, keeping source file attributes, show human readable progress,
#and delete files afterwards from destination if file exisits in destination but not in source
rsync -ah -r --progress source-file destination-file --delete-after
rsync Flags Reference
rsync have many possible flags to use. Below are a list of the flags according to the official manual:
Flags | Shorthand |
Description |
--verbose |
-v |
increase verbosity |
--quiet | -q | suppress non-error messages |
--no-motd | suppress daemon-mode MOTD (see caveat) | |
--checksum | -c | skip based on checksum, not mod-time & size |
--archive | -a | archive mode; equals -rlptgoD (no -H,-A,-X) |
--no-OPTION | turn off an implied OPTION (e.g. --no-D) | |
--recursive | -r | recurse into directories |
--relative | -R | use relative path names |
--no-implied-dirs | don't send implied dirs with --relative | |
--backup | -b | make backups (see --suffix & --backup-dir) |
--backup-dir=DIR | make backups into hierarchy based in DIR | |
--suffix=SUFFIX | backup suffix (default ~ w/o --backup-dir) | |
--update | -u | skip files that are newer on the receiver |
--inplace | update destination files in-place | |
--append | append data onto shorter files | |
--append-verify | --append w/old data in file checksum | |
--dirs | -d | transfer directories without recursing |
--links | -l | copy symlinks as symlinks |
--copy-links | -L | transform symlink into referent file/dir |
--copy-unsafe-links | only "unsafe" symlinks are transformed | |
--safe-links | ignore symlinks that point outside the tree | |
--copy-dirlinks | -k | transform symlink to dir into referent dir |
--keep-dirlinks | -K | treat symlinked dir on receiver as dir |
--hard-links | -H | preserve hard links |
--perms | -p | preserve permissions |
--executability | -E | preserve executability |
--chmod=CHMOD | affect file and/or directory permissions | |
--acls | -A | preserve ACLs (implies -p) |
--xattrs | -X | preserve extended attributes |
--owner | -o | preserve owner (super-user only) |
--group | -g | preserve group |
--devices | preserve device files (super-user only) | |
--specials | preserve special files | |
-D | same as --devices --specials | |
--times | -t | preserve modification times |
--omit-dir-times | -O | omit directories from --times |
--super | receiver attempts super-user activities | |
--fake-super | ||
--sparse | -S | |
--dry-run | -n | |
--whole-file | -W | |
--one-file-system | -x | |
--block-size=SIZE | -B | |
--rsh=COMMAND | -e | |
--rsync-path=PROGRAM | ||
--existing | ||
--ignore-existing | ||
--remove-source-files | ||
--del | ||
--delete | ||
--delete-before | ||
--delete-during | ||
--delete-delay | ||
--delete-after | ||
--delete-excluded | ||
--ignore-errors | ||
--force | ||
--max-delete=NUM | ||
--max-size=SIZE | ||
--min-size=SIZE | ||
--partial | ||
--partial-dir=DIR | ||
--delay-updates | ||
--prune-empty-dirs | -m | |
--numeric-ids | ||
--timeout=SECONDS | ||
--contimeout=SECONDS | ||
--ignore-times | -I | |
--size-only | ||
--modify-window=NUM | ||
--temp-dir=DIR | -T | |
--fuzzy | -y | |
--compare-dest=DIR | ||
--copy-dest=DIR | ||
--link-dest=DIR | ||
--compress | -z | |
--compress-level=NUM | ||
--skip-compress=LIST | ||
--cvs-exclude | -C | |
--filter=RULE | -f | |
-F | ||
--exclude=PATTERN | ||
--exclude-from=FILE | ||
--include=PATTERN | ||
--include-from=FILE | ||
--files-from=FILE | ||
--from0 | -0 | |
--protect-args | -s | |
--address=ADDRESS | ||
--port=PORT | ||
--sockopts=OPTIONS | ||
--blocking-io | ||
--stats | ||
--8-bit-output | -8 | |
--human-readable | -h | |
--progress | ||
-P | ||
--itemize-changes | -i | |
--out-format=FORMAT | ||
--log-file=FILE | ||
--log-file-format=FMT | ||
--password-file=FILE | ||
--list-only | ||
--bwlimit=KBPS | ||
--write-batch=FILE | ||
--only-write-batch=FILE | ||
--read-batch=FILE | ||
--protocol=NUM | ||
--iconv=CONVERT_SPEC | ||
--checksum-seed=NUM | ||
--ipv4 | -4 | |
--ipv6 | -6 |
|
--version | ||
--help | (-h) |