How to back up the system in Ubuntu

Source: Internet
Author: User
Today, I accidentally ended a process that I don't know how to use. As a result, the process failed to enter the x interface, while the running of the running machine, as a result, the entire X-related software package needs to be deleted, so the system had to be reinstalled. To prevent similar problems from occurring next time, the system was backed up. There are two backup methods: one is to use a software copy, and the other is to back up through the command line. The method of software backup is to download a software called UCloner, is http://code.google

Today, I accidentally ended a process that I don't know how to use. As a result, the process failed to enter the x interface, while the running of the running machine, as a result, the entire X-related software package needs to be deleted, so the system had to be reinstalled. To prevent similar problems from occurring next time, the system was backed up.

There are two backup methods: one is to use a software copy, and the other is to back up through the command line.

The method of software backup is to download a software called UCloner, is the use of http://code.google.com/p/ucloner/ compressed package has explained that I do not say more, but because the software said only support Ubuntu 10.10 10.04 and 9.10, therefore, you must use the command line to back up data in other versions.

The following describes how to back up the Ubuntu system:

Open the terminal and enter the following command:

1. Become Root User: sudo su
2. Go to the root directory: cd/

Then, the following is the complete command that I used to back up my system:

Tar-cvpzf/media/sda7/backup. tgz -- exclude =/proc -- exclude =/lost + found -- exclude =/mnt -- exclude =/sys -- exclude =/media/

Next, let's explain a little:
Tar is a backup program.
C-create a backup document
V-verbose mode. The tar program outputs all information on the screen in real time.
P-Save the permission and apply it to all files.
Z-use 'gzip 'to compress the backup file to reduce the size of the backup file.
F-indicates the path where the backup file is stored./media/sda7/backup. tgz indicates the backup file name in this example. The backup file is backed up in another partition, that is, the original WIN partition. Because my root directory does not have enough space, I only need to back up it elsewhere.

-- Excloude-exclude the specified directory so that it is not backed up

Let's take a look at the directories we want to include. We don't have to back up everything, because some directories are useless. Make sure that you do not want to include the file, otherwise you will get a very strange result. You do not need to back up anything in the/mnt directory, unless you have other partitions attached to it or you insist on backing up. You must also ensure that no resources are stored in the/media Directory (for example, any CD or mobile storage media). Otherwise, remove/media.

The last parameter is the directory we want to save. We want to save everything and use/as the root directory.

When I used this method for backup, what will I be prompted at the end:Tar:Error exit delayed from previous errors

Of course, you may display Chinese characters. In other words, it means something wrong. I checked it online and said it was caused by insufficient permissions. However, if you still use the Root permission, it is best to use Live usb for backup, because it may be possible to back up data during running. (Some people say this prompt can be ignored)

How to back up with Live usb:

Open the terminal and enter the following command:

1. Become Root User: sudo su
2. Go to the root directory: cd/

3. Create a directory: mkdir/

4. mount/dev/sdax/a in the root directory.

5. Go to the directory cd/.

6. Back up tar-cvpzf/media/xxx/backup. tgz *

 

Then we will restore the Ubuntu system backup:

Warning: Please. For God's sake, please be careful. If you do not understand what you are doing, it is very likely to overwrite your important data, so please be very careful!

Note !!! Because tar restoration only overwrites the same files, but this method only restores the files during backup, that is, if some files are lost or damaged, they can be restored and repaired, however, you cannot delete other files generated during the period from backup to recovery. To put it bluntly, if you have backed up the four files 1234 on the system, if three days later, for some reason, it is changed to 1234 '5 (4 changed). After recovery, it is changed to 12345, where 4 is restored to the file during Backup and 5 is retained. Therefore, if you want to completely restore the file to a backup file, you 'd better delete all the files in the root directory and restore the file to the backup file.

Now, let's continue with the example above. We created a backup file named backup. tgz in the directory of another partition (sda7.

One of the wonderful things in Linux is that it can be restored when the system is running, without the need to start a CD or any other mess. Of course, if your system has crashed, you must choose to use live CD, but the results are still the same.

Now, let's get down to the truth. This is the command I want to use. If your backup is not in the same position as mine, modify/media/sda7 accordingly:

Tar-xvpzf/media/xxx/backup. tgz-C/

If you are using bz2 compressed:

Tar-xvpjf/media/xxx/backup.tar.bz2-C/

If the system has crashed, you can use Live usb to log on, and then

Mkdir/tmp/root
Mount/dev/sdaX/tmp/root

Tar-xvpjf/media/xxx/backup.tar.bz2-C/tmp/root

Of course, you can first rm-rf/tmp/root/* before recovery, so that you can clean up. (Delete all files in the root directory as mentioned earlier)

This is only restored on the local machine. If it is restored to another machine, remember to modify the fstab file.. (You may also need to install grub)

At the end of the recovery command, your work has not been completed. Do not forget to recreate the directories excluded during Backup:
# Mkdir proc
# Mkdir lost + found
# Mkdir mnt
# Mkdir sys
# Mkdir media
And so on.

This is the way to back up the Linux system. You may not need to back up the system at all, but you have no trouble. Who knows whether to restore the system.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.