Ubuntu full backup and recovery

Source: Internet
Author: User
Tags uuid gparted

Backup:
Here is the complete command I used to back up the system:

TAR-JPCVF ubuntu-12.04-20131018.tar.bz2--exclude=/proc--exclude=/lost+found--exclude=/ ubuntu-12.04-20131018.tar.bz2--exclude=/mnt--exclude=/sys--exclude=/home/

Let's take a brief look at this command:
"Tar" is, of course, the program we use to back up our systems.
"JPCVF" is the tar option, meaning "Create profile", "Keep permissions" (keep everything original permission), BZIP2 format package, this is a compression time-consuming but high-compression format, often used to compress big data.
"UBUNTU-12.04-20131018.TAR.BZ2" is the file name of the archive file we are going to get.
"/" is the directory we want to back up, here is the entire file system.

The –exclude does not require a packaged directory. Some directories are useless, such as "/proc", "/lost+ found", "/sys". Of course, the "ubuntu-12.04-20131018.tar.bz2" file itself must be excluded, otherwise you may get some out of the ordinary results. If you do not exclude "/mnt", other partitions that are mounted on "/mnt" will also be backed up. Also need to confirm that "/media" does not mount anything (such as CD-ROM, mobile hard disk), if there is a mount thing, must be "/media" also excluded. Some people will ask, why I also ruled out. This folder is primarily about customizing some information for users. My computer, there is only one root user,/home file, nothing. What to exclude, for each individual.
Packing process is long, my system, just a 5G, packed the package 2.4G, took half an hour. When packaging is complete, there is a hint error, no tube.

Overall recovery
The steps to recover the system are much more cumbersome than the backup, and here are the main steps, and I'll try to explain what each step means.
Restart your computer via Ubuntu startup USB drive or CD-ROM and enter Ubuntu mode.
Open terminal in trial mode in Ubuntu, Run command (ctrl+alt+t)

sudo su-

Switch to root permissions

GParted

Open the partition software gparted under Linux, if prompted to install, run

sudo apt-get install gparted

Partitions are then made.

I've only divided three districts, Sda1,sda2,sda3 later, for swap partitions,/partition/home partitions
Unzip the backup archive package

Mkdir/tmp/root  

Booting to live Ubuntu mode with a USB stick does not actually mount your physical partition, so you need to mount the mount command to manually attach the/partition you just formatted and extract the compressed package into the import. Create a new two directory/tmp/root/tmp/root2, and mount the partition/dev/sda2/dev/sda3 to both directories separately. Make sure that sda2 is the partition that is mounted/directory after System Restore, Sda3 is the original/home directory mount partition, which has the backup compression package that we need exists. (I was copied through the mobile hard disk here) after the mount,/tmp/root corresponding to the SDA2 partition, that is, after the recovery/partition,/tmp/root2 corresponding to the SDA2 partition, restore the home/home partition. Entering the/tmp/root2/is where our original backup storage is located. Run sudo tar-jpxvf ubuntu-12.04-20131018.tar.bz2-c/tmp/root do the decompression operation, JPXVF X refers to the decompression,-c/tmp/root specifies the need to extract the target directory, here is actually sda1 The root directory where the partition resides. When this is done, all the data has been restored to the SDA1 partition
Recovering grub/mbr information for a partition
After formatting, partitioning, and so on, even if you are recovering your system on an existing hard drive, the UUID of the partition may have been changed, so the boot boot information that was backed up in the compressed backup package, such as: GRUB/MBR, is no longer matched to the current actual information, so we do the repair work.

Ls-al/dev/disk/by-uuid


Review the UUID information for each partition again to ensure that the UUID is consistent with the UUID used in the/tmp/root/etc/fstab
The system will not start correctly without the correct UUID and the partition directory mount match
Rebuilding the System directory
These directories are the directories that were appended to the –exclude parameter when we did the backup.

Mkdir/tmp/root/proc/tmp/root/lost+found/tmp/root/mnt/tmp/root/sys/tmp/root/home

The final step is to fix the bootloader running in live Ubuntu mode:

Add-apt-repository ppa:yannubuntu/boot-repair apt-get update apt-get install-y boot-repair Boot-repair

Download run Startup Repair software Boot-repair, click on the default recommended mode after launch.

If you want to know what this software does, you can see the steps for manual repair here. However, as the author does not verify its correctness, there is no guarantee that it will be available.
Tip: During the repair process, you will receive
Such a hint, dot yes or no, will go into

This interface. Finally also prompted not my network .... Obviously there is a network, this software is installed through the apt-get, how may not have the network, the reason I do not know. Anyway, when this interface is present, it can be restarted. I'm just like that, no problem anyway. Here, the system is back to completion.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Ubuntu full backup and recovery

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.