Just moozing

Before you can check your notes, you must make them…

Backup – take 2

with one comment

It have tried to do some elaborate backup system, and it has failed me due to complexity, so I never use it. It needs to be done differently, so let’s try the command line 🙂

The basic idea is still to do some md5 hashing and use squashfs to make large files that may be mounted into the directory structure.

Moving the stuff to the server

The process is fairly simple.

  1. Create file with all md5 sums of original
  2. Copy original to new location
  3. Create file with all md5 sums of copy
  4. Compare and handle any differences.

To create the recursive md5sum files I use md5deep and sometime (depending on the specific copying method) the result need to be sorted.

md5deep -lre . > ../md5.original.txt
cd ..


md5deep -lre . > ../md5.copy.txt
cd ..

sort -k1 md5.original.txt > md5.original.sorted.txt
sort -k1 md5.copy.txt > md5.copy.sorted.txt

tkdiff md5.copy.sorted.txt md5.original.sorted.txt

Note that the md5 sums must be aligned properly in the two files, and that makes the sorting relevant. To show the differences I use tkdiff.

And this exploded in my face. The example below illustrates the problem.

$ cp win/ELMER/morten/iso/Backtrack/bt4-final.iso tmpcopy/bt4-final.iso
$ cp win/ELMER/morten/iso/Backtrack/bt4-final.iso tmpcopy/bt4-final2.iso
$ md5sum -b tmpcopy/bt4-final*
500d9974ef0a2d79e63d811f4a3bf65e *tmpcopy/bt4-final.iso
500d9974ef0a2d79e63d811f4a3bf65e *tmpcopy/bt4-final2.iso
$ md5sum -b win/ELMER/morten/iso/Backtrack/bt4-final.iso
d41d8cd98f00b204e9800998ecf8427e *win/ELMER/morten/iso/Backtrack/bt4-final.iso

An md5 sum that reappears a lot d41d8cd98f00b204e9800998ecf8427e. This is the md5 sum of an empty file (or string)

WTF, copying is ok, but I’m unable to md5sum the file on the remote share (cat also shows an empty file)

Previously, the share was mounted using smbnetfs, so we mount it as root manually to compare.

# mount -t cifs -o user=morten,uid=1000 //ELMER/morten /mnt/elmer/morten
# exit
$ cd /mnt/elmer/morten/iso/Backtrack/
$ md5sum bt4-final.iso -b
af139d2a085978618dc53cabc67b9269 *bt4-final.iso

$cp /mnt/elmer/morten/iso/Backtrack/bt4-final.iso ~/tmpcopy/bt4-final3.iso
$cp /mnt/elmer/morten/iso/Backtrack/bt4-final.iso ~/tmpcopy/bt4-final4.iso

$ md5sum -b bt4-final*
500d9974ef0a2d79e63d811f4a3bf65e *bt4-final2.iso
af139d2a085978618dc53cabc67b9269 *bt4-final3.iso
af139d2a085978618dc53cabc67b9269 *bt4-final4.iso

Using smbnetfs, we get the same md5 sum when copying twice and an empty file on the server. Using mount.cifs as root, gives (a consistent) different md5sum, and the same when md5summing from the server.

Copying the file using windows, gives the af139d2a085978618dc53cabc67b9269 md5 sum for the file. Checking this with google tell me that this is the official md5 sum for the bt4-final.iso image.

The conclusion is that smbnetfs does something odd, and that mount.cifs is the way to go.

Apparently the squashfs part will have to wait for next time 🙂


Written by moozing

September 6, 2012 at 09:00

Posted in Tech

Tagged with , , ,

One Response

Subscribe to comments with RSS.

  1. […] post is just a follow-up on the other backup post, so tell everybody that I put the scripts on […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: