Ubuntu full backup and recovery, personally summarized, measured reliably

Source: Internet
Author: User
Tags root access

78227496

Ubuntu full backup and recovery, personally summarized, measured reliably

Beginners in the use of Ubuntu Linux operating system, often due to improper operation caused the system crashes, re-install the system is inevitable. The reinstall system is simple, but the various software/environment re-download, configuration is quite time-consuming, it is necessary to backup the system, so as to avoid the future even where the cry can not be found. This tutorial has been done by the JK Monk on the computer, can restore the previous Ubuntu system software and environment configuration, the method is simple, worthy of promotion:

First, the backup system

Use tar. Unlike Windows, Linux does not restrict root access to anything, you can throw everything on the partition into a tar file.

    1. Open a terminal, and run sudo su (enter the password after the request);

    2. Proceed to the system root by entering the following instruction in the terminal:
      $ cd /

    3. Start the backup system and enter it in the terminal:
$TarCvpzfBackuptgz -- Exclude=/proc --exclude=/lost< Span class= "hljs-literal" >+found - -exclude=/backup.tgz --exclude=/ MNT --exclude=/sys --exclude=/media              
    • 1

Let's take a brief look at this command:

    • ' Tar ' is the program used to back up
    • C-Create a new backup document
    • V-verbose mode, the TAR program will output all the information in real time on the screen.
    • P-Save the license and apply it to all files.
    • Z-compress backup files with ' gzip ' to reduce the volume of backup files.
    • F-Indicates the path where the backup file is stored, ubuntu.tgz is the file name in this example.
    • "/" is the directory we want to back up, here is the entire file system.
    • Directories that must be excluded from the backup are given between the file name "Backup.tgz" and the Directory Name "/" to be backed up. Some directories are useless, such as "/proc", "/lost+ found", "/sys". Of course, the "backup.tgz" 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.
    • After the backup is complete, a file named "Backup.tgz" will be generated at the root of the file system, and it may be very large in size. Now you can burn it to a DVD or put it where you think it's safe.
      At the end of the backup command you may see a hint: ' Tar:error exit delayed from previous errors ', in most cases you can ignore it.
Second, recovery system
    1. If the original Ubuntu system has crashed, it cannot be entered. You can use the Ubuntu install USB drive (live USB) to enter the Ubuntu interface.

    2. Switch to the root user and locate the disk partition where the root directory of the previous Ubuntu system is located (the disk partition on the general computer (assuming the partition name is Sdax) can be found in the media directory under the root directory of the current Ubuntu system (i.e.,/media). The directory is typically the cd/media/disk name/partition name under the current root directory. Enter the partition and enter the following instructions to delete all files under the root directory:
      $ sudo rm -rf /media/磁盘名称/分区名称*

    3. Copy the backup file "Backup.tgz" into the partition;
      $ sudo cp -i backup.tgz /media/磁盘名/分区名sdaX

    4. Enter the partition and unzip the compressed file, and the parameter x is to tell the TAR program to unzip the backup file.
      $ sudo tar xvpfz backup.tgz

    5. Recreate the directories that were excluded from the backup;
      $ sudo mkdir proc lost+found mnt sys media
      or this:
      mkdir proc
      mkdir Lost+found
      mkdir MNT
      mkdir SYS

When you restart your computer, you'll find everything back to what you did when you created your backup!

--written by a young monk from Hkust, 2017.10.13

Ubuntu full backup and recovery, personally summarized, measured reliably

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.