I have a Time Machine-style backup system set up on my NAS (running BusyBox v1.16.1), using rsync --link-dest
as described here: http://blog.interlinked.org/tutorials/rsync_time_machine.html
Is there an easy way to find out which files will be deleted if I delete an old backup directory, and which will just be unlinked? I assume one way would be to find which inodes in the old directory have only one link to them, but I don't know a way to do that. rm --dry-run
anyone?
Bonus Points: Find a way to do the above, and also calculate the total disk space freed if the old backup is deleted.
Answer
A simple way would be to just use find with the -links
option.
Specifically you would want to do something like find path -type f -links 1
.
I haven't tested, but I believe a command like this would delete all the multi-linked files.
# you might not need to escape the !, depends on your shell
# should find all the files that do NOT have a link count of 1 and delete them
find path -type f \! links 1 -print -delete
No comments:
Post a Comment