Monday, November 15, 2010

Article: Restoring individual files from a Linux system state backup

Hey all!

[Abstract]
In this post i will show how to restore individual files from a system state backup made with dd.

[Prerequisites]
This is a follow up post to my earlier posts Linux system state backup and Restoring a Linux system state backup. However it should work with any image file made with dd.

This method has been tested on Ubuntu 10.10 x64 server edition but should work on most Unix-based operating systems.

[General]
In my previous posts i discussed ways of making a system state backup on Linux using the dd command. I also explained how to restore it in the case of a complete failure of either the system or the disk.
But what if you just need to restore a single file or directory? Perhaps you made a change to smb.conf and now nothing works. Do you need a separate backup for just the files? Of couse not!

[Restoring individual files]
To restore individual files from a backup just follow these simple steps.
1. Locate the backup file you wish to use. In this example i will restore some files from yesterdays backup. The backup file is /mnt/data1/Backup/20101114/sda1.img.gz.
2. In my case the file is compressed so I make a temporary copy of it in /mnt/temp1 and then I run gzip -d sda1.img.gz
3. After a few minutes the decompressing is complete and we need to make a mount point. I choose /mnt/restore to keep it simple. Issue the following command: sudo mkdir /mnt/restore
4. Finally we simply need to mount the file using this command mount -o loop sda1.img /mnt/restore
5. Now you can browse through the file system and copy any files you want. When you're done you unmount the file using unmount /mnt/restore

[You might run in to trouble]
I have no idea why but i got some pretty intermittent and odd errors when testing this at the time of writing. The mount and unmount commands would issue a weird error but still work and when repeated moments later work without error.
Please try and see if it works, otherwise repeat and it might work that time.

I also had some trouble mounting a specific image file, mount claimed the filesystem might be corrupt. I'll look into that some more and see if i can find something out.

Feel free to ask any questions or add comments regarding this post in the comments. I'll try and answer best i can, promise.

Cheers

No comments:

Post a Comment