Computing/Linux/Rsync: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
(New page: *Rsync is a program useful for making backups *If a file was originally in both source/ and destination/ (from an earlier rsync, for example), and you delete it from source/, you probably...)
 
No edit summary
Line 1: Line 1:
*Rsync is a program useful for making backups
*Rsync is a program useful for making backups.  Example:
/usr/bin/rsync -a /home/username/ /path/to/backupdir


*If a file was originally in both source/ and destination/ (from an earlier rsync, for example), and you delete it from source/, you probably want it to be deleted from destination/ on the next rsync:
*If a file was originally in both source/ and destination/ (from an earlier rsync, for example), and you delete it from source/, you probably want it to be deleted from destination/ on the next rsync:
Line 7: Line 8:
*rsync -a /source/ /dest - copy contents of "source"; result: /dest/sourcefiles
*rsync -a /source/ /dest - copy contents of "source"; result: /dest/sourcefiles


*Useful options:
  -a, --archive
  -a, --archive
               This  is equivalent to -rlptgoD. It is a quick way of saying you
               This  is equivalent to -rlptgoD. It is a quick way of saying you

Revision as of 14:52, 25 October 2007

  • Rsync is a program useful for making backups. Example:
/usr/bin/rsync -a /home/username/ /path/to/backupdir
  • If a file was originally in both source/ and destination/ (from an earlier rsync, for example), and you delete it from source/, you probably want it to be deleted from destination/ on the next rsync:
rsync -a --delete source/ destination/
  • rsync -a /source /dest - copy "source" directory; result: /dest/source/sourcefiles
  • rsync -a /source/ /dest - copy contents of "source"; result: /dest/sourcefiles
  • Useful options:
-a, --archive
             This  is equivalent to -rlptgoD. It is a quick way of saying you
             want recursion and want to preserve almost everything.
             Note however that -a does not preserve hardlinks, because  find-
             ing  multiply-linked  files  is  expensive.  You must separately
             specify -H.
-r, --recursive             recurse into directories
-l, --links                 copy symlinks as symlinks
-p, --perms                 preserve permissions
-t, --times                 preserve times
-g, --group                 preserve group
-o, --owner                 preserve owner (root only)
-D, --devices               preserve devices (root only)
--exclude=PATTERN       exclude files matching PATTERN (--exclude ´*~´)
--delete-excluded       also delete excluded files on the receiving side