Dev Notes

Various Cheat Sheets and Resources by David Egan/Carawebs.

Incremental Timestamped Local Backup


BASH, Backup, Linux, Sysadmin, rsync
David Egan

This script creates a backup at regular intervals - you can backup every minute if necessary.

The backup is incremental, so very efficient in terms of space and system resources.

#!/bin/sh
#

date=$(date "+%Y-%m-%d-%H:%M:%S")
rsync -aP --link-dest=$HOME/Backups/current /home/david/Documents $HOME/Backups/back-$date
rm -f $HOME/Backups/current
ln -s back-$date $HOME/Backups/current

# After running:

david@david-desktop:~/Backups$ ls -la
total 28
drwxrwxr-x   5 david david  4096 Jun 26 17:39 .
drwxr-xr-x 149 david david 12288 Jun 27 09:56 ..
drwxr-xr-x   3 root  root   4096 Jun 26 17:39 back-2015-06-26-17_39_06
drwxr-xr-x   3 root  root   4096 Jun 26 17:39 back-2015-06-26-17_39_25
drwxr-xr-x   3 root  root   4096 Jun 26 17:39 back-2015-06-26-17_39_36
lrwxrwxrwx   1 root  root     24 Jun 26 17:39 current -> back-2015-06-26-17_39_36

Resources

This script is based on this article.


comments powered by Disqus