electroZ microsystems

Checking backup


If you want to compare your large backup on a server with your local filesystem in order to be sure everything is backuped one way is to do the listing of all your files in both side and then compare only the listing with a graphical tool like WinMerge on Windows or Meld on Linux.

How to generate a listing of a large directory? We can use Linux and Cygwin in a Windows 7 or XP machine.

The commande line could be

  ls -lR>fileListing.txt


But in that case we could get difference in user name and group since we are on different machine. So we could use instead this command


  find .  -exec  stat -c"%n >%s< (%z)" {} \; >fileListing.txt


Which will generate a line by file with this format:

  [[./Altium09/HOWTO]] >0< (2010-07-15 09:10:27.908559700 +0200)

But in that case working copy and backup copy could have a different date but still be equal. So we could use the 'MD5SUM' function to check the all content of the file. This is a quite slow process.

  find -type f -exec md5sum {} \; |tee filesListing.txt

Which will generate a line by file with this format:

  b03bb78e95ff0e7013bab73221f5f06f *./project/Images/Asc.gif

This solution seems to be good but in some server the "find command" result can find files in a different order not nessesary alphabetic. In order to work around that let see the bash commands below.

  find . -type f -not -path "*.svn*" |tee fileList.txt
  sort fileList.txt > fileListSorted.txt
  while read line; do md5sum $line; done < fileListSorted.txt |tee fileList.md5

Then we can do the same in an other directory and compare with Meld or use the standard md5sum command.

  md5sum -c fileList.md5


So in Meld we see wich files are missing or are changed.


Fichier:MeldFileChange.png