Friday, June 13, 2008


Backing up a USB to a Gmail account

A few days ago, I found that my trusted 1 GB USB drive was exhibiting apparent corruption. Some of the directories gave listings in which the file names were garbled. Fortunately I think that the files in these directories weren't mission critical. However, I became concerned that valuable files that were on the root of USB drive might disappear too. I was on the road - so my back up options were limited. However, the following commands rapidly salvaged, compressed, encrypted, and stored on gmail what was left on my drive. These commands might be useful to you, if you find yourself in similar circumstances. And, if you know what causes USB directory listing corruption, and how to avoid it, and/or recover from it, please let me know!

# Commands to extract data from a USB drive and copy to gmail for storage
# Firstly, copy what you can from your USB drive to a directory
# called (in this case) 'save'
mkdir save
cd save
cp -r e:/stuff .

# create a tar file of that saved directory
cd ..
tar -cvzf save.tgz save

# encrypt the tgz file
ccrypt -e < save.tgz > save.tgz.backup

# split the tgz file into ~ 10 MB chunks
split -b10000000 save.tgz.backup

# now mail the chunks to your gmail account

for file in x*
echo $file
echo $file | mutt -a $file -s $file

# To reassemble the information on the USB drive you will need to download
# each of the chunks, reassemble them into the encrypted .tgz file, with:

cat x* > temp.tgz.backup

# then decrypt them with:

ccrypt -d < temp.tgz.backup > temp.tgz

# and finally un-tar the data

tar xvof ./temp.tgz
Comments: Post a Comment

<< Home
Newer Posts Older Posts