Linux backup and restore of the entire system

 It is very important to back up the system. If one day the system crashes, you can reinstall the system, but after reinstalling the system, you need to perform related configurations, which will be very troublesome and waste a lot of time.

The way of backup:

        There are two backup methods

                1.tar command backup system

                2.dd command lossless backup system (system clone)

Here I use the tar command to back up the entire linux system.

1. Enter the root directory

command: cd /

2. Backup system

Enter the following command to perform a system backup:

#The backup file is linux_backup_11_8.tar.xz

tar -Jcvpf linux_backup_11_8.tar.xz

#Excluded folders are these.

#Backup files do not need to be backed up (otherwise there will be an infinite loop)

--exclude=/linux_backup_11_8.tar.xz

#Linux boots of different computers are different, so no backup is required

--exclude=/boot

#Different computer equipment is different, no backup is required

--exclude=/dev

# Externally mounted files do not need to be backed up

--exclude=/mnt

#Data files in memory do not need to be backed up

--exclude=/proc

#Data files in memory do not need to be backed up

--exclude=/sys

#Target backup file root directory

/

start backup system

 

It may take a long time to back up here. You can go out and see the great mountains and rivers in China.

After the backup is complete, you can see the following files

You can use this compressed file for system recovery later.

3. System Restore

When our root user accidentally deletes the /home directory, we can use our backup files for system restore.

From this, we found that the root user deleted the home directory.

So we need to perform a system recovery.

Enter the command to restore our system backup to the system

Command: tar -Jxvf linux_backup_11_8.tar.xz -C /

 The recovery process is as follows.

 

 

restore complete

 Then restart the system to restore the system to the original backup.

 

Guess you like

Origin blog.csdn.net/weixin_53064820/article/details/127755481