Ubuntu backup and recovery

Source: Internet
Author: User
Tags root access


Before using ubuntu for backup and recovery, I believe many people have experienced using Windows. If you have backed up a Windows system, you must remember: First, you need to find a backup tool (usually private software), and then restart your computer to enter the software environment provided by the backup tool, back up or restore the Windows system. Norton Ghost is a common backup tool used to back up Windows systems.
When backing up a Windows system, you may have thought about whether I can put the entire c drive in a ZIP file. This is impossible in Windows, because many files in Windows are not allowed to be copied or overwritten during their running. Therefore, you need dedicated backup tools for special processing on Windows. Unlike backing up Windows systems, if you want to back up Ubuntu systems (or any other Linux system), you no longer need backup tools like Ghost. In fact, Ghost and other backup tools have poor support for Linux file systems. For example, some Ghost versions can only fully support Ext2 file systems. If you use it to back up Ext3 file systems, you may lose some valuable data. Www.2cto.com 1. How can I back up my Ubuntu system? It's easy to use TAR just like backing up or compressing other things. Unlike Windows, Linux does not limit root access to anything. You can throw everything in the partition to a TAR file! First become a root user: $ sudo su and then enter the root directory of the 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 back up, including remote directories or directories on mobile hard disks): # cd/the complete command I used to back up the system: # tar cvpzf backup. tgz-exclude =/proc-exclude =/lost + found-exclude =/backup. tgz-exclude =/mnt-exclude =/sys/Let's take a simple look at this command: "tar" is of course the program we used to back up the system. "Cvpfz" is the tar option, which means "create a file", "retain Permissions" (Retain the original permissions for everything), and "use gzip to reduce the file size ". Www.2cto.com your backup.gz "is the file name of the file to be obtained. "/" Is the directory to be backed up. Here it is the entire file system. A directory must be excluded during Backup is provided between the file name “backup.gz and the directory name to be backed up. Some directories are useless, such as "/proc", "/lost + found", and "/sys ". Of course, the “backup.gz file must be excluded, otherwise you may get some results beyond common sense. If "/mnt" is not excluded, other partitions mounted on "/mnt" will also be backed up. In addition, make sure that "/media" does not mount anything (such as a CD or a mobile hard disk). If there is a mount, "/media" must also be excluded. Some people may suggest you exclude the "/dev" directory, but I think this is very inappropriate. The specific reason is not discussed here. Before executing the BACKUP command, check whether the command you typed is what you want. It may take a short time to execute the BACKUP command. After the backup is complete, a file named "backup. tgz" will be generated in the root directory of the file system. The file size may be very large. Now you can burn it to a DVD or put it somewhere you think is safe. At the end of the Backup command, you may see the following prompt: 'tar: Error exit delayed from previous errors ', which can be ignored in most cases. Www.2cto.com you can also use Bzip2 to compress files. Bzip2 has a higher compression ratio than gzip, but it is slower. If the compression rate is important to you, you should use Bzip2, replace "z" in the command with "j", and give the file a correct extension "bz2 ". Complete command: # tar cvpjf backup.tar.bz2-exclude =/proc-exclude =/lost + found-exclude =/backup.tar.bz2-exclude =/mnt-exclude =/sys/2. be careful when restoring the system! If you do not know what you are doing, you may lose important data. Be careful! Next, we use the example above. Switch to the root user and copy the file "backup. tgz" to the root directory of the partition. One wonderful thing in Linux is that you can restore the system in a running system without using boot-cd for special guidance. Of course, if your system has crashed and cannot be started, you can use Live CD to start it. The effect is the same. You can also use a command to kill all files in Linux. Of course, I am not going to give this command here! Run the following command to restore the system: # tar xvpfz backup. tgz-C/if your file is compressed using Bzip2, use: # tar xvpfj backup.tar.bz2-C/www.2cto.com. Note: the preceding command overwrites all files in the partition with files in the archive file. Before executing the recovery command, check whether the command you typed is what you want. It may take a short time to execute the recovery command. 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! By hensen_hhc

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.