Friday, November 21, 2008

How to backup and restore your system ?

(Linux System)

Step 1:

Log in as root :

Tyoe sudo su and enter your password when asked...

deep@deep:~$ sudo su

[sudo] password for deep: -------(type your password )

Step 2:

Get into the root of your file system

Type cd /

root@deep:/home/deep# cd /

Step 3:

Type the following command to backup your system

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

This command is going to create archive backup.tgz

Incase you want to compress your back up type the following command ...remember the more compression the lower will be speed do this only if compression is necessary for you

tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

To be noted...we have just changed cvpzf to cvpjf and the archive name to backup.tgz to backup.tar.bz2

Note:

  • Remember we have excluded some directories which are:

  • proc

  • lost+found

  • backup.tgz

  • mnt

  • sys

  • Don't try to exclude a particular file which may produce unweird result.

  • Make sure that you don't have anything mounted in media (cds or any other removable media )

This is all you do to backup your system. It takes a while and then you have your back up ready.

Restoring:

Its very important to know what you are doing else you will overwrite your system which might contain your important data.

As in making back up you need to be root and make sure that the backup file is also in the root of the filesystem.

Type the following command :

 tar xvpfz backup.tgz -C /

Incase you have used the compression step while backing up your system instead of above command type the following :

 tar xvpfj backup.tar.bz2 -C /

Warning : This will overwrite every single file on your partition with the one in the archive .

Very Important

I guess you remember the directories we have excluded at the time of making back up so its important to create all those before you do anything for that type the following:


mkdir proc

mkdir lost+found

mkdir mnt

mkdir sys

....etc

And then reboot your system ,,,everything should be the way it was when you made the backup...


Note: This way of creating an archive doesn't imply to Microsoft related Operating system as you must have all known that you cannot copy or overwrite files while they are being used.

No comments: