Beginner Rsync

Rsync comes pre-installed on many systems including Red Hat, Ubuntu and Solaris. Rsync is a useful tool for performing remote backups. It is very efficient as it only backs up the changes or differences in tany changed files rather than the whole file.

BASIC EXAMPLE – LOCAL BACKUPS:

In this example you can use rsync to perform a backup from your local system to another location on your local system. This could be used to back up files onto a mounted filesystem or another hard disk. It is similar to the copy (cp) command but more efficient.

rsync -av /home/jonny/temp/source/ /home/jonny/temp/destination

The 'a' option is for all files and 'v' is for verbose. I have a trailing slash on the source directory otherwise the rsync command will create a directory

/home/jonny/temp/source/destination/backedupfiles

rather than

/home/jonny/temp/source/backedupfiles

 BASIC EXAMPLE – REMOTE BACKUP:

 To backup a directory from a local machine to a remote machine asecure shell account is needed on the remote machine and the command for a remote machine named 'barney' would be:

rsync -a –delete -e ssh /home/jonny/temp/rsync/source/ jonny@barney:/home/jonny/rsync/ 

The delete option ensures that any files deleted in the source directory will be deleted in the remote directory. This ensures you keep a mirrored backup without the junk. On logging in you are asked for your password on the remote system.

 

SCHEDULING BACKUPS

To schedule backups on a *nix system you would obviously use Cron.

crontab -e 

An add an entry for your backup e.g.

10 2 * * * /usr/bin/rsync -a --delete /home/jonny/source/ destination/
 

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>