Backup your Linux OS is the first thing I want to do after installing my Linux machine and necessary softwares. You can install your OS again but it takes long time and effort to install all the stuffs in your machine. Now I start to backup and restore my Ubuntu 9.10. It’s the same to the other distributions.
Before we start, let’s make sure that you have root permission to do all the things.
Step 1. Start to backup:
# tar cvpzf backup.tgz –exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
The command above creates a compress file of all the system except from /proc, /lost+found, /mnt and /sys directories. However, you need to unmount all partitions such as flash drive, network drive..., if you don’t want to run out of memory for your backup file.
It takes about 5-10’ to backup your system. For better compression, you can use the command below to backup your OS (take more time).
# tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found –exclude=/backup.tar.bz2 --exclude=/mnt –exclude=/sys /
Step 2. Restore your machine:
If you want to restore your OS just type the following command in the command line.
# tar xvpfz backup.tgz -C /
OR
# tar xvpfj backup.tar.bz2 -C /
In worst cases, you can’t get into your machine. Let’s use live cd (Ubuntu, CentOS...) to get into the command line. Then decompress your backup file to restore your system.
* Note: There are some other ways that may work when backup your system. First, I think you can use Norton Ghost (Hirent’s Boot Disk) to ghost your whole disk. Second, you can copy your hard disk to another disk (http://www.itbox4vn.com/2011/06/how-to-copy-content-of-one-hard-disk-to.html).
Have fun!