Transfering a Folder Recursively to Another Machine With rsync (Push or Pull)
rsync is an awesome program built into Linux to copy files. It can do both pushing and pulling of files:
Pushing Files
sudo rsync [OPTION...] [USER@]HOST:SRC... [DEST]
Example of Pushing a Directory Recursively:
sudo rsync -rt /var/www/html/coolFiles timmanz@192.168.1.86:/home/mydir/InterestingStuff
Pulling Files
You can also initiate the transfer on the receiving machine. The syntax is as follows:
sudo rsync [OPTION...] SRC... [USER@]HOST:DEST
Example of Pushing a Directory Recursively:
sudo rsync -rt timmanz@192.168.1.86:/home/mydir/InterestingStuff /var/www/html/coolFiles
rsync Options:
These are some of our favorite rsync options. Read more on the man page.
-v, –verbose increase verbosity
-q, –quiet suppress non-error messages
–no-motd suppress daemon-mode MOTD (see caveat)
-c, –checksum skip based on checksum, not mod-time & size
-a, –archive archive mode; equals -rlptgoD (no -H,-A,-X)
–no-OPTION turn off an implied OPTION (e.g. –no-D)
-r, –recursive recurse into directories
-R, –relative use relative path names
–no-implied-dirs don’t send implied dirs with –relative
-b, –backup 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)
-u, –update 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
-d, –dirs transfer directories without recursing
-l, –links copy symlinks as symlinks
-L, –copy-links transform symlink into referent file/dir
–copy-unsafe-links only “unsafe” symlinks are transformed
–safe-links ignore symlinks that point outside the tree
-k, –copy-dirlinks transform symlink to dir into referent dir
-K, –keep-dirlinks treat symlinked dir on receiver as dir
-H, –hard-links preserve hard links
-p, –perms preserve permissions
-E, –executability preserve executability
–chmod=CHMOD affect file and/or directory permissions
-A, –acls preserve ACLs (implies -p)
-X, –xattrs preserve extended attributes
-o, –owner preserve owner (super-user only)
-g, –group preserve group
–devices preserve device files (super-user only)
–specials preserve special files
-D same as –devices –specials
-t, –times preserve modification times
-O, –omit-dir-times omit directories from –times
–super receiver attempts super-user activities
–fake-super store/recover privileged attrs using xattrs
-S, –sparse handle sparse files efficiently
-n, –dry-run perform a trial run with no changes made
-W, –whole-file copy files whole (w/o delta-xfer algorithm)