Cleanup hardlink from a backup with hardlink (rsync like)


Here is a small script to remove hard link of a rsync based backup, by days.
I have use it to cleanup my backup and find when different version of file have been created.

find . -type d > dir_list0
# my dir list is of the form ./2010/07/22/home
cat dir_list0 | cut -f1-5 -d/ | grep home | sort | uniq  > dir_list

# delete all hardlink, keep just the one is the oldest dir
cat dir_list | while read i; 
    find "$i" -type f -links +1 -delete
#delete broken symlink
find . -type l -xtype l -delete
#delete emtpy dirs
find . -type d -empty -delete

One response to “Cleanup hardlink from a backup with hardlink (rsync like)”

Leave a Reply

Your email address will not be published. Required fields are marked *