Jun
10
2011
Uncategorized

Restore your Linux Backup

In my previous post on Backup your Linux System, a brief introduction on Backup and the three types of Backup were explained. Once we have backups of our important documents, we should be able to restore those backups. Ergo, in this post, I will explain how to restore backups using the GNU version of ‘tar’ Backup Utility.

But, before you begin reading this post, I highly recommend you to go through ‘Backup your Linux System’ if you are not confident in backing up your system.

 

Restoring ‘Full Backup’

Step 1.

cd into the directory holding the archive.

Step 2.

# tar -xpzf backup.tar.gz -C /home/rabi

Here, backup.tar.gz is the archive i.e. the source file and /home/rabi is the path to restore  the files in the archive.

 

Restoring Incremental Backup

While performing Incremental Backup, we had created Snapshot files (as our test.snar file mentioned in previous post ). A Snapshot file is a standalone file that helps to determine which files have been changed, added or restored since last backup. Since, GNU tar will delete all those files that did not exist in their directories when the archive was created, we must be careful with Snapshot files.

Step 1.

cd into the directory holding the archives.

Step 2.

# tar -xpzf  backup0.tar.gz  --listed-incremental=/dev/null -C  /home/rabi

(This file should be a level 0 backup file. )

Step 3.

# tar -xpzf backup1.tar.gz  --listed-incremental=/dev/null -C /home/rabi

(This file should be a level 1 backup file. )

and so on..

Similarly, we can restore Differential Backups provided we know the order of our Snapshot files.

 

List files in the archive

If you are not sure what files are in the archive, you can use the –list or -t option to peek in the archives.

# tar --list  --file  backup.tar.gz

Reconstitute the Splitted Archive

I had shown you how to split the archive during creation or after the creation. So, now we will be reconstructing the complete archive.

Step 1.

cd into the directory holding the split archives.

Step 2.

# cat *tar.gz* | tar -xvpzf - -C /

(This will write all the archives into one and pass all that through standard output to tar to be extracted into root.)

 

Restore -bzip2 archive

# tar -xvpjf backup.tar.bz2  / home/rabi 

Subscribe to fortystones.
Follow @fortystones on Twitter.
Get updated from our Facebook Fanpage.

Share

About the Author: Rabi C Shah

Rabi C Shah, pursuing his under-graduate program with a major in Information Technology in Indian Institute of Information Technology Allahabad (IIIT-A), is a passionate programmer. A Photoshop enthusiast, he is interested in Linux, C and C++. Rabi has completed many mini college projects in java and php. He is the Linux guy of our fortystones team.

2 Comments + Add Comment

Leave a comment

*