ubuntu system backup and recovery

Before using Ubuntu, I believe many people have had the experience of using Windows system. If you backed up the Windows system, then you must remember: first of all need to find a backup tool (usually proprietary software), and then restart the computer into the software environment to provide backup tool, where the backup or restore Windows system. Norton Ghost is a backup tool often used when backing up Windows systems.

When backing up Windows systems you may thought, if I can put the entire C drive are placed in a ZIP file to go yet. This is not possible under Windows, because there are a lot of files at run-time they are not allowed to copy or covered in Windows, so you need a special backup tool for Windows system special treatment.

Backup and Windows systems, if you want to back up Ubuntu system (or any other Linux systems), you no longer need a backup tool such as Ghost. In fact, Ghost backup tool for this type of support Linux file system is very bad, such as some versions of Ghost can only improve support for Ext2 file system, if you use it to back up Ext3 file system, you may lose some valuable data.

1. Backup System

How do I back up my Ubuntu system? Very simple, just as you back up or compress other things, the use of TAR. Unlike Windows, Linux does not restrict root access to anything, you can put everything on the partition is thrown into a TAR file to go!

First become root:

$  su

Then enter the root file system (of course, if you do not want to back up the entire file system, you can also enter the directory you want to backup, including remote directory or directory on your hard disk mobile):

# cd /

Here is the full command I used to back up the system:

As a rookie, in the process to Linux, the Linux often lead to a variety of errors, recoverable or unrecoverable (at least in the present case), so, for me, backup and restore on Linux particularly important.

1. Backup

a) directly backup the entire file system ( '/') through the tar, but there are few points to note:

i. can not back up the following files (directory)

1. The current archive

2. / proc folder

3. / lost + found folder

4. / mnt folder i. Select

5. / sys folders

6. / media folder

b) Therefore, the command is:

 

tar cvpzf backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.gz --exclude=/mnt --exclude=/sys --exclude=/media /

1. Note: p option to save the current authority on behalf of

 

2. Restore

a) Linux can then travel system is to restore the system, if the current startup can not start, can be started by live cd and perform recovery operations

b) operating below

tar xcpfz backup.tar.gz -C /

c) the need to create additional directory

1. mkdir proc

2. mkdir lost+found

3. mkdir mnt

4. mkdir sys

Let's take a quick look at this command:

"Tar" of course, is that the program we are using a backup system.

"Cvpfz" is tar option, which means "creating an archive," "Keep rights" (the original rights reserved all things), "Use gzip to reduce the file size."

"Backup.gz" 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.

Must be excluded directory between the archive file name "backup.gz" and the name of the directory to be backed up "/" gives the backup. Some directories are useless, for example, "/ proc", "/ lost + found", "/ sys". Of course, "backup.gz" The archive itself must be excluded, otherwise you might get some results beyond common sense. Without the "/ mnt" excluded, then mount the "/ mnt" other partitions will be backed up. Also need to make sure it does not mount anything (such as optical disks, removable hard disk) on "/ media", if there is to mount something, must be "/ media" are also excluded.

Some might suggest that you put "/ dev" directory excluded, but I think it is wrong, the specific reasons not discussed here.

Please reconfirm before you perform a backup command you typed the command is not what you want. Perform a backup command may take a while for some time.

After the backup is complete, the root of the file system will generate a file named "backup.tgz", and its size can be very large. Now you can burn it onto a DVD or put you think a safe place to go.

At the end of the backup command you might see a prompt: 'tar: Error exit delayed from previous errors', in most cases you can ignore it.

You can also use Bzip2 to compress files, Bzip2 compression ratio than gzip, but the speed is slower. If the compression ratio is very important to you, then you should use Bzip2, use "j" instead of command "z", and a correct extension "bz2" to the archive. The full command is as follows:

# tar cvpjf backup.tar.bz2 –exclude=/proc –exclude=/lost+found –exclude=/backup.tar.bz2 –exclude=/mnt –exclude=/sys /

2. Recovery System

Be careful when operating the system during recovery! If you do not know what you're doing, you're likely to lose important data, please be careful!

Then the above example. Switch to root, and the file "backup.tgz" copied to the root directory of the partition.

In Linux, there is a very wonderful thing is that you can restore the system in a running system without the need to specifically guide with boot-cd. Of course, if you can not hang the system has been activated, you can use the Live CD to start, the effect is the same. You can also use a command to all files in the Linux system to kill, of course, here I do not intend to give this command!

Use the following command to restore the system:

# tar xvpfz backup.tgz -C /

If your archive using Bzip2 compression should be used:

# tar xvpfj backup.tar.bz2 -C /

Note: The above command will overwrite all files on the partition with the files in the archive.

Please confirm before executing the order to resume the command you typed is not what you want, do the restore command may take a while for some time.

Resume command ends, your work is not finished, do not forget to re-create those directories when backups are excluded:

  1.  
    # mkdir proc
  2.  
    # mkdir lost+found
  3.  
    # Mkdir mnt
  4.  
    # mkdir sys

and many more

When you restart the computer, you will find everything restored to look like when you create a backup!

Guess you like

Origin www.cnblogs.com/chenjiye/p/11332387.html