In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to carry out the backup and recovery of Linux system, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Copy of the tar command (backup the entire system locally, restore it later or restore it to this machine)
Note that there is enough free space in the root directory for backup.
Cd / # tar.gz format tar cvpzf system_backup.tar.gz /-- exclude=/proc-- exclude=/lost+found-- exclude=/system_backup.tar.gz-- exclude=/mnt-- exclude=/sys#tar.bz2 format tar cvpjf system_backup.tar.bz2 /-- exclude=/proc-- exclude=/lost+found-- exclude=/system_backup.tar.bz2-- exclude=/mnt-- exclude=/sys# recovery system cd / # upload files to the root directory tar xvpfz system_ Backup.tar.gz-C / or tar xvpfj system_backup.tar.bz2-C / # the directory mkdir procmkdir lost+foundmkdir mntmkdir sys that is excluded when creating a backup
/ proc permission: file owner: root group: root owner: read execution group: read execution group: read execution other: read execution / lost+found permissions: file owner: root group: root owner: read write execution group: read execution other: read execution / mnt permission: file owner: root group: root owner: read write execution group: read write execution group Read execution other: read execution / sys permissions: file owner: root group: root owner: read write execution group: read execution other: read execution
After the recovery is completed, everything will be exactly the same as when you backed up.
Mirror (native backup system, restore to the new host) 1, check the system version, install the same version of the system on the target machine (minimum installation), partition format, type is the same (I have not tried a different situation, I do not know whether it can succeed) lsb_release-auname-adf-Thfree-h3, backup source system # exclude dev,tmp because the hardware configuration of the target machine and the source host are different And then appropriately add the files you want to exclude, such as:-- exclude=/root/*.bz2# here there is plenty of space under mnt, so save it to mnt. 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 to the target host scp / mnt/system_backup.tar.gz root@192.168.0.166:/mnt3, and start it with ISO, LiveCD, etc. Mount the disk (usually automatically mount to the / media folder) sudo-s cd / media/# backup the UUID,# in the important configuration file / boot/gurb/gurb.cfg / etc/fstab record to delete duplicate files # delete all the folders except some folders that were excluded when backing up the system above, such as dev mnt media sys. Rm-rf root home usr lib lib64 etc var bin sbin opt boot run selinux vmlinuz initrd.img# restore backup mount / dev/vda1 / mnt/1# be careful not to write / directory here, it will hang up the existing system! It should be the mounted directory tar xvpfz system_backup.tar.gz-C / mnt/1cd / mnt/1 # at this time you can see the structure of the root directory, but editing the fstab file finds that it is the fstabchroot of the existing system. / # after executing chroot, it will take the. / directory as the root directory, then the edited file is the real target source file. After restore, modify the UUID in / etc/fstab to the information in the file you just backed up, and note that the partition format should also correspond. Modify the UUID in / boot/gurb/gurb.cfg to the information in the file you just backed up. Modify the network card and IP configuration file in case IP cannot be allocated. (if it is a virtual machine, remember to add a network card and configure a medium-performance graphics card.) if there are services that depend on the original platform, such as built-in NTP,Agent and other monitoring programs; turn off the service, turn off boot self-boot; Ubuntu: enter runleve on the command line to view the current running level. Generally, the default is 2 to view the S-starting service in the / etc/rc2.d directory. Inside is a soft link, if you want to add, then you can build a link file, S stands for start, followed by the number is the startup sequence, delete the soft link. Delete the corresponding script under / etc/init.d/ at the same time. Vim / etc/init.d/rc.localCentos: after completing the above steps with systemctl, exit # exits chrootcd ~ umount / mnt/1# and restarts the system without accident (all the accounts set when the system was installed disappear after startup; the account is the same as the source host). If you boot Grub prompt "boot error 15: Error 15 file not found" solution: please check the GRUB related files of the kernel file location. It is usually related to the / boot partition. If the boot Grub prompt "dracut:dono't how to hand root=f078" solution: change the root=UUID to root=/dev/sdaX this format. If the boot system prompts / usr/libexec/gconf-sanity-check-2 exit status 256the solution: chmod 777 / tmp
Rsync command
Note that the format of the target partition is preferably NTFS, FAT, EXT and so on, to avoid the problem that files larger than 4G cannot be backed up.
# it is better to have other partitions or external storage devices. Mount them and df-lh to see the mount point. # backup rsync-Pa / / media/usb/backup_20170410-- exclude=/media/*-- exclude=/sys/*-- exclude=/proc/*-- exclude=/mnt/*-- exclude=/tmp/*# restore rsync-Pa / media/usb/backup_20170410 /
Dd command
The dd command is a sector clone, and the target partition is larger than the backup partition, and even the unused space will be cloned as is, which will be slow.
# backup df-h # View the partition where the system is located, dd if=/dev/sda1 of=/dev/sdb3 # backup sda1 to sdb3 # restore dd if=/dev/sdb3 of=/dev/sda1 # restore sdb3 to sdb1 what is a Linux system Linux is a free-to-use and free propagation UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system Using Linux, you can run major Unix tools, applications, and network protocols.
After reading the above, have you mastered the method of how to backup and restore Linux system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.