How to backup and restore the Ubuntu system

How to backup and restore the Ubuntu system

by admin on June 5, 2009

In this post, I would like to introduce the easiest way to backup and restore the Ubuntu system from my experiences.For more information about backup and restore you can see this post

I am usually doing crazy with my system so it is really necessary to backup the system file before dong such things :)

Backup

The basic idea is using Tar command. I recommend to backup your system and your personal data separately to avoid the very big backup files and the system file is more important than anything else.

The basic command is:

sudo tar cvpjf backup.tar.bz2  --exclude=/sys  /

We should exclude some directories because of some reasons:

  1. I usually mount other partions under /media directory, but someone they usually mount under /mnt directory. So we should exclude /media and /mn.
  2. Folder: /var/cache/apt/archives we should remove from backup file because it stores the cache apt files, we don’t need to make the backup file smaller. After several days, if you forget to delete those files, your backup file will get bigger.
  3. Folder: /home we should exclude because we will store the personal data separately.
  4. Foder /tmp we can exclude because it stores the temp files only.
  5. Of course, the backup file before: backup.tar.bz2

Finally, we get the backup commands are: ( I include all necessary commands also)

cd /
sudo tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found \
--exclude=/backup.tar.bz2 --exclude=/var/cache/apt/archives \
--exclude=/mnt --exclude=/media --exclude=/home --exclude=/tmp  --exclude=/sys /

So just copy those commands and paste on your terminal by using the hotkey: Ctr + Alt + V

For backuping your home data, you can do the same way without or with exclude some directories like:

- Browse to the user directory, let’s assume /home/ngohaibac

cd /home/ngohaibac

- Backup by using tar command and exclude some folders I don’t want to backup

sudo tar cvpjf backup_home.tar.bz2  --exclude=~/store  --exclude=~/backup_home.tar.bz2  .

Store

To get backme the system at the backup time, I recommend you a good way to do:

Step 1

Boot your system using Live Ubuntu CD and delete all directories: /usr, /var, /etc, /bin in the Ubuntu partion. You can use the command like: sudo rm -fr /media/ubuntu_mout_point/usr

Step 2

Restore all files by using tar command:

- Browse to that partion: let’s assume /media/disk

cd /media/disk

- Restore all data:

sudo tar xvpfj backup.tar.bz2 -C  .

Wait for a moment, and reboot your system, now you can get your system again.

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)

Related posts:

  1. How to setup Video calls in Skype on 64-bit Ubuntu system Skype is a software to make free video and voice calls, send instant messages and share files with other Skype users. You can use Skype in almost famous platforms: Windows, Linux, Mac OS and for your mobiles as well. For Linux users, you can easily download and install Skype binary package from here. With the 32-bit [...]...
  2. Sound Solutions on Ubuntu system I had great chance to visit ubuntuforums.org when I tried to finger out the sound solution of Ubuntu system because the sound is not really good enough compared to listen in Windows OS. The threat is very great, you can see here. And now they update some information for Ubuntu Jaunty 9.04 here. This post [...]...
  3. How to configure Windows Firewall for FTP Server At this moment, I am using one Windows Server 2008 running on an VPS (Virtual Private Server). Like before, I always want to setup system by myself to make sure to know what is on my system. The first time, I was thinking to use Linux server, but I changed my mind at last to [...]...

Leave a Comment

Previous post:

Next post: