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.3_1094]
Rating: 0.0/10 (0 votes cast)

Related posts:

  1. Howto Install and setup TFTPD in Ubuntu workstation I was doing my own project using TMS320DM355 EVM with MontaVista realtime Linux is installed some months ago.  At that time, I search in Google many times but I didn’t get success to install TFTP. Finally, I found out one great tutorial about that. In my system, I use TFTP protocol to download Linux kernel, [...]...
  2. How to install Picasa in Ubuntu Homepage: http://picasa.google.com Today, I am going to upload my pictures from last party, I suddenly remember a such powerful and great image management: Picasa from Google. Actually, I love Google products because of their simple characteristics. Picasa application can run cross-platform on Linux and Windows OS as well. In Windows, it use this one also. [...]...
  3. Howto install Vietnamese Input Method Scim-Unikey on Ubuntu Today, I would like to introduce the Vietnamese input method in Ubuntu. Scim-Unikey is the most stable package for typing Vietnamese characters, by combining the advantages of Smart Character  Input Method (SCIM) and the most famous Vietnam input method Unikey. Scim-Unikey now is maintained by Ubuntu-VN and Vietnamese Ubuntu Community. If you want to learn [...]...
  4. 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 [...]...
  5. How to upgrade Pidgin and fix Yahoo problem in Ubuntu 9.04 Some days ago, I couldn’t even sign in my Yahoo account in Pidgin. At that time, I guessed that having some problems and was waiting for upgrade version of Pidgin. Finally, the new version 2.5.7 has been released on 20th June wih new bug fix. Version 2.5.7 (06/20/2009) Yahoo Protocol 16 support, including new HTTPS [...]...
  6. The best CHM Viewer in Ubuntu Linux What is CHM ? Let’s have a look at Wikipedia: Microsoft Compiled HTML Help is a proprietary format for online help files, developed by Microsoft and first released in 1997 as a successor to the Microsoft WinHelp format. It was first introduced with the release of Windows 98, and is still supported and distributed through [...]...

Leave a Comment

Previous post:

Next post: