Wednesday, July 17, 2013

GUIDE: Restoring Windows Vista/7 backup files under Linux

If you've recently upgraded from Windows to Linux but now need to restore the backup files you made with Windows Backup (or need to restore someone else's), you've come to the right place!

The Windows Backup Format

Unlike the Windows NT BKF backup format, the Windows Vista/7 Backup utility uses regular ol' zip files to store data. Well, almost. Windows Backup (for some reason) splits the backups it makes into many parts, making restoring the files a pain. On my system, I got over 1000 zip files.

Microsoft's webpage suggests opening these (over 1000) zip files one by one to try and find my file. Yeah, right.

Luckily for us, the awesome power of BASH automation makes the job surprisingly simple.

What to do

Let's say that I want to recover the file Mr Bean at the Olympics.mp4 from my backups (true story!).
  1. Open up a terminal window.
  2. cd to the directory where the many, many zip files are stored.
    cd "/media/Seagate Expansion Drive/MY-LAPTOP/Backup Set 2013-06-10 103426"
  3. Run the following command, replacing the file name with the one you are looking for:
    for f in *.zip; do echo $f; unzip -l "$f" | grep 'Mr Bean at the Olympics.mp4'; done;
  4. A whole bunch of zip file names will flash by. Look for the line(s) that look something like
    Backup files 647.zip
     19129617  2013-06-10 15:48   C\Users\User\Desktop\Mr Bean at the Olympics.mp4
  5. This tells us that the file is located inside Backup files 647.zip.
  6. If you have too many zip files, you can use the alternative command:
    for f in *.zip; do echo $f>>/tmp/a.txt; unzip -l "$f" | grep 'Mr Bean at the Olympics.mp4'>>/tmp/a.txt; done;
    This will save the results of the search in /tmp/a.txt. Open this file up and use the search feature to find the relevant lines.

File listed in one zip file

If the output you got from the above command looks something like
Backup files 647.zip
 19129617  2013-06-10 15:48   C\Users\User\Desktop\Mr Bean at the Olympics.mp4
then congratulations! You get the easy way out. All you need to do is open up the relevant zip file and extract your file.

File listed in more than one zip file

If the output you got from the above command looks something like
Backup files 647.zip
 19129617  2013-06-10 15:48   C\Users\User\Desktop\Mr Bean at the Olympics.mp4
Backup files 648.zip
 19129617  2013-06-10 15:48   C\Users\User\Desktop\Mr Bean at the Olympics.mp4
Backup files 649.zip
 19129617  2013-06-10 15:48   C\Users\User\Desktop\Mr Bean at the Olympics.mp4
then unfortunately, there's a bit more work involved.
  1. Open up the first zip file (in this case, Backup files 647.zip).
  2. Extract the file.
  3. Rename the file, giving it a sensible name, putting -1 at the end (in this case, it would be Mr Bean at the Olympics.mp4-1).
  4. Go through the rest of the zip files, repeating steps 1 to 3, but using -2 and -3 and so on.
  5. You should now have several files:
    Mr Bean at the Olympics.mp4-1
    Mr Bean at the Olympics.mp4-2
    Mr Bean at the Olympics.mp4-3
    ...
  6. Go to the terminal and type:
    cat "Mr Bean at the Olympics.mp4-1">>"Mr Bean at the Olympics.mp4"
    cat "Mr Bean at the Olympics.mp4-2">>"Mr Bean at the Olympics.mp4"

    and so on.
  7. Finished! You can now delete all the -1 and -2... files.

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home