Join the group!

Resources

Articles‎ > ‎

Rsync Mini Howto

posted Sep 29, 2010 1:42 PM by Mike Perry
Simply copying files as a non-root user can be done as the following.

rsync -ax /source/ /target

When copying an entire file system as root it is a bit more complex.

rsync -aHSKvz /source/ /target

This copies all files from /source to a /target. All files are copied
including things like devices and links.  If the slash at the end of source is
omitted, you will end up with a source directory under target instead
of target being the root.

If source is / you probably want to exclude files under /proc and
/sys.
--exclude="/sys/*" --exclude="/proc/*"

Using -x is another option depending on your needs.

Source and target can be a remote host by using the following syntax.

user@hostOrIp:/path

In some cases you  may have to specify '-e ssh' to your argument list.

Common argument definitions:

 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
  -r, --recursive           recurse into directories
  -l, --links               copy symlinks as symlinks
  -p, --perms               preserve permissions
  -t, --times               preserve modification times
  -g, --group               preserve group
  -o, --owner               preserve owner (super-user only)
  -D                        same as --devices --specials
    --devices               preserve device files (super-user only)
    --specials              preserve special files
-H, --hard-links            preserve hard links
-S, --sparse                handle sparse files efficiently
-K, --keep-dirlinks         treat symlinked dir on receiver as dir
-z, --compress              compress file data during the transfer

Some other useful options are:
-A, --acls                  preserve ACLs (implies -p)
-X, --xattrs                preserve extended attributes
-x, --one-file-system       don't cross filesystem boundaries
-P                        same as --partial --progress
  --progress              show progress during transfer
  --partial               keep partial files when interrupted