30 Kasım 2012 Cuma

BackUp Your Linux System with TAR

People using a lot of specific configurations in their Linux systems may want to back up their systems in order not to do the same configurations if system fails.
There are several ways to back up your linux system:
1) The first and the low-level one is "dd" command which dumps the whole disk byte-wise. Since my Ubuntu system was almost 200GB in size, it takes very long time both back-up and restoring.
2)The second option is to use some programs like "CloneZilla". There is a lot of information about usage of these softwares, if you google it.
3)As a Linux user, you can do this just by using TAR command to archive your linux system and reuse it if necessary.

BACK-UP with TAR:
1) Prepare your system before TAR: You can delete all unnecessary files, folders etc for smaller image sizes. You can delete your personal files and internet history not to include them in your back-up image. Do not forget to unmount extra hard-drives mounted un your system(extarnal hdd etc.)
2) After preparation we can take our back-up now.
Open the terminal.
cd /
tar -cvpzf backup.tar.gz --exclulde=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev /
 We are archiving with "preserve file permisions" options -p- and "gzip" option -z-. Also note that some unnecesary directories are excluded. For instance, /dev directory is a tmpfs directory created by udev at every startup. We do not need it while archiving the system.
After a while, the back-up process will finish. You may see a line saying: "Exiting with failure status due to previous errors". Do not take this message into account. Now you can check whether your backup.tar.gz file is located under root. You can copy the image to another folder or hard-disk if you wish for later usage.


RESTORING
If you are restoring root directory, you shall use a Live CD. Start the system with your Live CD, mount the relevant drive and take care about the correct paths for the commands.
Assuming your backup.tar.gz is located under /home/test, the command is:
tar -xvpzf /home/test/backup.tar.gz -C /
After extraction process do not forget to recreate the directories excluded before:
mkdir /proc /lost+found /sys /mnt /media

Time to reboot your computer to check if restoring is OK!..

If you encounter problems at GRUB boot, check internet for instructions.
https://help.ubuntu.com/community/GrubHowto#Backup,%20Repairing%20and%20Reinstalling%20GRUB

References
https://help.ubuntu.com/community/BackupYourSystem/TAR

Hiç yorum yok:

Yorum Gönder