Rotate your Rsync Backups with rotate-backups, similar to Time Machine

I use rsync on gnome-ubuntu 15.10 to back up my data to my server running Debian 8. This creates incremental backups similar to Apples Time Machine. The backup runs every 2 hours so this creates more backups than needed at the expense of hard drive space. I used to manually delete the files from the server and would try to save a monthly backup, 8 weekly backups, 30 daily backups, and 2 weeks of every 2 hour backups. This was a time consuming process of manually selecting the files and thus I was not consistent about removing the extra backups. My backup scripts are written in python and I was going to write a script that would delete old backups that were not needed any more. Even better than writing your own script is finding one that has already been written such as This script will automatically delete your old backups and you can configure it for many backups you want to keep.

This script is well documented and easy to use. I give it my highest recommendation.

Rename File with Current Date in Debian 8 Linux

I had a need to rename a file with the current date after running a backup script. This was done on Debian 8 Linux. The backup script would make a file name called “/mnt/“. I like my backup files with year-month-day at the front of the filename for easy sorting by date. My format is 2016-0422 for the date of April 04, 2016. I am using the date command to insert the current date and this is command that runs automatically after the backup command is run.

mv /mnt/ /mnt/$(date “+%Y-%m%d.webmin.tar.gz”)

This results in a new filename of “/mnt/

Here are an example of testing the date command from the command line.

Create a file “delete.txt”

touch delete.txt

Copy the file to a new name with current Year-MonthDay.delete.txt format

cp -v delete.txt /root/$(date “+%Y-%m%d.delete.txt”)

The output of the command on 2016-0422 was:

‘delete.txt’ -> ‘/root/2016-0422.delete.txt’

The command was run successfully.