Dev Notes

Software Development Resources by David Egan.

Using rsync to Copy Incremental Backups


Backup, Linux, Rsync, Sysadmin
David Egan

Copy a directory comprised of incremental backup to a separate hard disk.

When an incremental backup makes use of hardlinks, these need to be preserved when copying the backup directory. Otherwise, all files are copied individually, taking up a lot more space on the destination directory.

File Format
If copying to an external drive, it should be formatted to an ext3 or ext4 filesystem. FAT(32) formatting won’t work - it doesn’t support permission & ownership data

When rsync’ing with the -a option, hardlinks are NOT automatically preserved:

Note that -a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify -H.

rsync Man page

Hardlinks are generally a critical element of incremental backups. Hardlinks allow multiple directory/file entries to be associated with a single inode. If you do not include the rsync -H argument, when copying a set of incrementally backed-up directories rsync would copy files in their entirety. This would lose the space saving benefits of the hardlinked incremental backup.

rsync Command

rsync -az --exclude='*.zip' -H --progress /source-drive/name /destination-drive

Explanation:

  • -a Archive mode; recursive, copy symlinks as symlinks, preserve permissions, preserve modification times, preserve group, preserve owner, preserve special & device files.
  • -z Compress the file data being transferred
  • --exclude='*.zip' do not transfer files with a .zip extension
  • -H Preserve hardlinks
  • --progress print info about the transfer (for the terminally bored, but at least you can see it’s doing something)

Note that the lack of a trailing slash on the source directory will result in this directory being created in the destination directory (if it doesn’t already exist).

References


comments powered by Disqus