Home arrow Guides arrow Rsync as a Backup Tool
Rsync as a Backup Tool PDF
Wednesday, 27 April 2011
If we need to regulary backup our data to a backup server rsync can be a choice for this task.

  cd /usr/ports/net/rsync
  make install clean
  rehash

To sync a source and a destination folders by timestamp we use:

  rsync -av source/ destination/

To sync files using checksum of files:

  rsync -avc source/ destination/

To sync files and also use compression:

  rsync -avz source/ destination/

To sync files and delete older files:

  rsync -av --delete-after source/ destination/

You can do a more verbose approach (displaing also transfer rates):

  rsync -artpvz --progress --stats source/ destination/

To only simualte the sync but not actually copy any file (this is also useful to compare two tree of files):

  rsync -an source/ destination/

To exclude some files from rsync process:

  rsync -avc --exclude /dir_to_exclude  source/ destination/

If you have many files to excluse, you can place exclude files in a text file and then run:

  rsync -avc --exclude-from 'exclude.txt' source/ destination/

Note: When using --exclude it will consider path from current directory and not from / (not from root directory) !

To rsync via SSH we use:

  rsync -avc source/  This e-mail address is being protected from spam bots, you need JavaScript enabled to view it :/~destination

Next command will treat symlinks as ordinary files:

  rsync -Lavc source/  This e-mail address is being protected from spam bots, you need JavaScript enabled to view it :/~destination

To rsync via SSH on a different port we use:

  rsync -e 'ssh -p 4444' -avc source/  This e-mail address is being protected from spam bots, you need JavaScript enabled to view it :/~destination

To rsync via SSH and also limit bandwidth we use:

   rsync -e 'ssh -p 22' -i --bwlimit=200 -avc source/  This e-mail address is being protected from spam bots, you need JavaScript enabled to view it :/~destination


Where:
- a stands for  archive mode, it will preseve rights/owner of files;
- v for verbose
- c will compare files using checksum

For more details see rsync man page which has lot of examples.
Last Updated ( Monday, 15 October 2012 )
 
< Prev   Next >

Other BSD Systems

OpenBSD

Misc

Solaris

Polls

Best BSD firewall?