The tar command
Copy (local backup of the entire system, later restore or restore to the local)
Ensure that there is sufficient free space in the root directory for backup.
Gz / --exclude=/proc --exclude=/lost+found --exclude=/system_backup.tar.gz Bz2 / --exclude=/ MNT --exclude=/sys #tar.bz2 tar CVPJF system_backup.tar.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/system_backup.tar.bz2 --exclude=/ MNT --exclude=/sys # restore the system CD / # Upload the file to the root directory tar XVPFZ system_backup.tar.gz -c / / tar XVPFJ system_backup.tar.bz2 -c / # mkdir proc mkdir lost+found mkdir MNT mkdir sysCopy the code
- /proc Permission: File owner: root Group: root Owner: read execution Group: Read execution Other: read execution
- /lost+found Permission: File owner: root Group: root Owner: Read write execute group: Read execute Other: Read execute
- / MNT Permission: File owner: root Group: root Owner: Read write Execute group: Read execute Other: read execute
- /sys Permission: File owner: root Group: root Owner: Read write Execute group: Read execute Other: read execute
After the restoration is complete and you restart, everything will be exactly the same as when you backed it up.
** Image (** Local backup system, restore to new host)
1, check the system version, install the same version of the system on the target machine (the most simple installation can be), partition format, type also (I did not try different situation, do not know whether successful) lsb_release -a uname -a df -th free -h 2, Dev, TMP; --exclude=/root/*.bz2 # --exclude=/root/*.bz2 # cd / tar cvpzf /mnt/system_backup.tar.gz / --exclude=/mnt/system_backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/ MNT --exclude=/sys --exclude=/dev --exclude=/ TMP --exclude=/media # Upload file to target host SCP/MNT /system_backup.tar.gz [email protected]:/ MNT 3, boot on the target with ISO, LiveCD, etc. /boot/gurb/gurb. CFG /etc/fstab Delete all files except for the dev MNT media sys folder that was excluded from the backup system. Rm -rf root home usr lib lib64 etc var bin sbin opt boot run selinux vmlinuz initrd.img # Mount /dev/vda1 / MNT /1 # Do not write/directory, it will ruin the existing system!! Tar XVPFZ system_backup.tar.gz -c/MNT /1 CD/MNT /1 / # The root directory of the fstab file is./. After restoration, change the UUID in /etc/fstab to the information in the backup file. Ensure that the partition format is the same. Example Change the UUID in /boot/gurb/gurb. CFG to the information in the file just backed up. Modify network adapter and IP configuration files to prevent IP address assignment failure. (If the VM is a VIRTUAL machine, add a NETWORK adapter and configure a medium performance graphics card.) If there are services that rely on the original platform, such as built-in NTP and Agent monitoring programs; Close the service and turn off the startup; Ubuntu: Run runleve on the cli to view the current operating level. The default operating level is 2. In the /etc/rc2.d directory, services starting with S are automatically started upon startup. Inside is a soft link, if you want to add their own link file can be built, S stands for start, after the number is the start order, delete soft link. At the same time, delete the script in /etc/init.d/. /etc/init.d/rc.local Centos: exit chroot CD ~ umount/MNT /1 No accident on the normal startup of the system (after the startup of the original installation of the system set up account all disappear; The account is consistent with the source host. If boot Error 15 :Error 15 File not found is displayed after Grub is started, check the location of the grub-related kernel file. Usually associated with /boot partitions. Dracut :dono't how to hand root=f078 "dracut:dono't how to hand root=f078" If the system prompts /usr/libexec/gconf-sanity-check-2 to exit 256, the solution is chmod 777 / TMPCopy the code
The rsync command
Note The format of the target partition must be NTFS, FAT, or EXT to avoid the problem that files larger than 4G cannot be backed up.
# Better have another partition or external storage device, mount well, df -lh see mount point. Rsync-pa / /media/ usB/backup_20170410 --exclude=/media/* --exclude=/sys/* --exclude=/proc/* --exclude=/ MNT /* --exclude=/ TMP /* # Restore rsync-pa /media/ USB /backup_20170410 /Copy the code
The dd command
The dd command is sector cloning. The target partition is larger than the backup partition. Even if no space is used, the target partition will be cloned unmodified, which is slow.
Dd if=/dev/sda1 of=/dev/sdb3 dd if=/dev/sdb3 of=/dev/sda1Copy the code
Source: www.leolan.top/index.php/p…