1

We have a slight problem with our backups. Our setup is as follows:

  • We create a backup using the rsync command.
  • The backup uses the option --link-dest option, to create incremental backups with hardlinks to older backups, for all the files that have not changed.

All looks well, every file we have checked so far that hasn't changed since the last backup gets hardlinked correctly (same inode number as the file in the older backup).

However, the last two weeks there has been a massive increase in storage need on the backup server. We suspect that either somthing is going wrong in our backup process, or massive files have been added (and/or changed) by users on the normal server.

We want to check (some of) the files that have been changed since the last backup; this means checking all files in the same directory structure with different inodes (no hard links).

How to find these files?

(Ubuntu 12.04 LTS)

  • A starting point might be find . -links 1 -type f. In future it might be a good idea to run rsync with -v --stats and archive the logging file. – mpy Jun 28 '14 at 12:46
1

I can think of two ways off the top of my head:

  1. Use find and limit the number of links

    find -type f -links 1
    

    The command above will find all files whose inode is only pointed to by a single link. This means that any files that point to the same inode as another will not be printed.

  2. List all inodes and show only the unique ones

    ls -1i | awk '{print $1}' | sort | uniq -u
    

    Note that the above will not print file names, only inodes. This is because i) it's the inodes that we need to sort/uniq and ii) file names can contain strange characters such as newlines which would break the sorting/uniqing. If you are confident that your file names are sane, you can use this approach to print file names:

    ls -1i | awk '{c[$1]++;l[$1]=$0;} END{for(i in c){if(c[i]==1){print l[i]}}}'
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.