Backup and rotate shell script – using rsync and sshfs

The other day I needed a shell script that could backup files and folders to a remote server using rsync as well as rotating the backups.

Rsync

I wrote a small script that does just this, it requires rsync and sshfs (available on Ubuntu as packages). I wrote the scipt to works as follows:

The machine which contains the data I wish to make a backup of runs this script at certain intervals using a Cron-job, one job for backing up the data and one for rotating the backups. The data is copied to a server which supports rsync over ssh and rotating the backup folders is done by mounting the remote filesystem using sshfs and then renaming folders. Continue reading