Tuesday, March 16, 2010

rsync command that makes two things the same

To update a copy of something:

$ rsync --archive --delete --hard-links --verbose --progress --dry-run SOURCE DESTINATION

this performs deletes (--dry-run to see what first!)

Note that the  syntax is sensitive to trailing slashes on the source:

To back up /home to a directory on an external drive, you probably want:

sudo rsync --archive --delete --hard-links --progress --dry-run /home/ /mnt/wdexternal/woc-desktop/home

as the command without the slash after /home/ will create a new subdirectory /mnt/wdexternal/woc-desktop/home/home

the short version has -avH for archive, verbose, hard-links.
delete, progress and dry-run appear to only be long options

verbose tells you what's being copied, progress gives you percentage copied so far for large files

quite often what I want is to backup a subtree in my home directory

$ rsync -avH dir/ old-dir

does the business in this case

No comments:

Post a Comment