Rsync
Rsync is one of those utilities that doesn't come nativity normally. Some flavors do install it during installation of the operating system while others demand you to install it.
You don't have to install it but it is good if you need to do some special tasks.
It's meant as a utility to synchronize two directories which in turn can be done in various ways. It can do it between two servers/computers or between two local directories or even as a server for others to synchronize with your local package.
Basic Command with Options
rsync -narvchtSR --delete-during --numeric-ids --exclude=.nfs\* --exclude=.snap --rsh="ssh -l root" :<source_directory> <destination_directory>
How to use Rsync to syncronize two directories
rsync -arvchtS --no-R --delete-during --numeric-ids
Examples
# rsync -arvchtS --no-R --delete-during --numeric-ids blaj/blaj2 blaj1
sending incremental file list
blaj2/
blaj2/du
blaj2/hej
sent 173 bytes received 54 bytes 454.00 bytes/sec
total size is 0 speedup is 0.00
# rm blaj/blaj2/hej
# rsync -arvchtS --no-R --delete-during --numeric-ids blaj/blaj2 blaj1
sending incremental file list
blaj2/
deleting blaj2/hej
sent 74 bytes received 16 bytes 180.00 bytes/sec
total size is 0 speedup is 0.00
Rsync and Basic options
rsync -narvchtSR --delete-during --numeric-ids --exclude=.nfs\* --exclude=.snap --rsh="ssh -l root" :<source_directory> <destination_directory>
- R = use relative path names
- z = compress file data during the transfer
- r = recurse into directories (need to be specified by itself)
- a = archive mode; equals -rlptgoD (no -H,-A,-X)
- l = copy symlinks as symlinks
- p = preserve permissions
- g = preserve group
- o = preserve owner (super-user only)
- v = increase verbosity
- t = preserve modification times
- c = skip based on checksum, not mod-time & size
- h = output numbers in a human-readable format
- n = perform a trial run with no changes made
- S = handle sparse files efficiently
- delete-during = receiver deletes during xfer, not before
- numeric-ids = don't map uid/gid values by user/group name
- exclude = exclude files matching PATTERN