While I don't have hard links (mainly soft links) in my working directories, I am using hard links in my incremental backup strategy. I implement the following simple script to create a rotating backup using rsync's --link-dest=[filename]. I would be curious to see what others thought of this approach to incremental backups:
#!/bin/bash
# Backup script written by JHDugger 4/26/12.
# Todays date in ISO-8601 format:
DAY1=`date -I`
# Yesterdays date in ISO-8601 format:
DAY0=`date -I -d "1 day ago"`
# The source directory:
SRC="/srv/tacs-host1/backup/"
# The target directory:
TRG="/srv/tacs-host1/archive/$DAY1"
# The link destination directory:
LNK="/srv/tacs-host1/archive/$DAY0"
# The rsync options:
OPT="-avh --delete --link-dest=$LNK"
# Execute the backup
rsync $OPT $SRC $TRG
#121 days ago in ISO-8601 format
DAY121=`date -I -d "121 days ago"`
#Delete the backup from 120 days ago, if it exists
if [ -d /srv/tacs-host1/backup/$DAY121 ]
then
rm /srv/backup/$DAY121
fi
This script creates a subdirectory with today's date under a directory called 'archive' and then proceeds to read changed files from the previous day's archive directory, copy and link any changed files from this directory to today's archive. It then proceeds to delete the directory that is 121 days old.