1. Back up your Linux system
Window System in the running state, we can not copy the file, then under Linux it? Her file structure is a tree-type structure. And we can package all the system files when the system is running. In particular, the root account of Linux has any operation on the system, which is why it is necessary to create a low-level user right to prevent system errors caused by the system crashes the halo. Look at the backup command below.
# switch to root
sudo su
# Enter the system root directory
CD/
# Execute Package Command
tar cvpzf linuxbackup.tgz--exclude=/proc--exclude=/lost+found--exclude=/linuxbackup.tgz--exclude=/mnt-- Exclude=/sys/
Command Explanation:
tar:linux Common packaging procedures
cvpzf: parameter of type tar, C-Create new document
output related information during V-processing
P-means keep the same permissions
Z-Call gzip to compress the archive, and invoke gzip to complete the decompression with-X
F-to-normal file operations
linuxbackup.tgz: The file name to package into
--exclude=/proc: Exclude/proc directory, do not package this directory, followed by the same, remember to exclude the file name of the package itself
/: Means to pack all files of the Linux root directory, of course excluded files are not included
The whole process is understood to mean, create a new file name linuxbackup.tgz compressed file, it saves the file from the specified directory, and save the original permission settings, here you must write down the directory you excluded, restore the need to manually create. Specifically which directories to exclude, this root feel different environment and work need to choose just. After execution wait for a certain time, copy this linuxbackup.tgz to other place, the backup is complete.
focus on: Do not do anything during the packaging process, otherwise you will modify some files, tar will prompt the error after the backup. Recovery is the same.
2. Restoring the Linux system
You can use this method to recover your backup files after you have backed up the system as described above. If your system crashes and you can't get into the system then you can use the boot CD or other boot system to enter, if you can enter the system, first copy the backup file to the/directory, and then execute the following command to restore the system:
#提升到root
sudo su
# Go to the root directory
CD/
# Decompression Recovery System
tar xvpfz linuxbackup.tgz-c/
after the execution, don't worry about the system, remember to create the directory you excluded in the backup, manually created, such as above we exclude, we need to create
mkdir proc
Mdkir Lost+found
mkdir mnt
mkdir SYS
You can restart the system at this time. The recovery is complete.
How can I back up and compress multiple directories and files of a Linux system to a file to maintain and pass on?