In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail what is the strategy of backup recovery and upgrade of Ubuntu system. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
In the initial use of the developer system, whether to build the Ubuntu system infrastructure, or to install and configure all kinds of software is a painstaking process: because the developer system is a system that requires mental cost in exchange for high efficiency, it is designed as a highly customizable and extremely free system, not to mention that you are free to configure and install the entire operating system from compiled source code. Even most commonly used software, such as vi,emacs, etc., can play countless modes of operation by changing the configuration file. Users need to take the time to change and try these configurations to make the way of operating these software * * their own habits and achieve efficient goals. Therefore, after a period of deployment, each Linux user will have his own efficient system, and if there are 1000 users, there will be 1000 dedicated efficient systems. The software and configuration methods installed on each system are different, and each user will spend a lot of energy and time in the process of building this exclusive system.
Losing your own proprietary system means a loss of time and energy, especially for a user who has been using Linux for a long time: users have accumulated too much software and operating habits on this system, and if they need to configure a new system from scratch because of a system crash, without any backup measures in advance, the rest will be a disaster. This is why experienced Linux users pay so much attention to backup. In view of this, the author introduces the backup recovery and upgrade strategy of Ubuntu system with some experience in this chapter.
These backup and recovery strategies are not only applicable to Ubuntu, but also for Linux users using other distributions, you can also refer to the following to slightly modify the steps.
Script recovery strategy; fully formatted updates
As we mentioned earlier, one of the features of the Ubuntu system is that you can download the required software from your own source through the apt-get command, so users can create a script file to back up the required software by writing common apt-get install commands (see the scripting section on saving a software installation in the cloud in the previous article) At the same time, add some specific steps for personalized configuration that require manual intervention, such as changing the specific steps to activate the shortcut key for Pinyin input method (most pinyin input methods preempt ctrl+space, and if you do not change it, developer users will not be able to use this shortcut to activate intelligent code prompts in IDE such as Eclipse), or for example: you may not be satisfied with the default font of Firefox Need to be replaced. These detailed steps should be recorded in the script in the form of comments. If these steps are too cumbersome, you can also find the corresponding configuration file after configuration and save it directly in Dropbox to facilitate future recovery of these configurations from the cloud to the local machine. For example, if you customize the behavior of Vim and add the Vim plug-in, you only need to back up ~ / .vimrc ~ / .vim in the cloud.
So once you have created such a script file, even if you need to reinstall the system or face a brand new computer, you only need to execute the script file and check the comments in the script to ensure that the software is not lost, the steps of configuring the software can be restored, and the important data is stored in the cloud: Dropbox (binary file), GitHub (text file, more on later). Naturally, the premise of this strategy is that you must maintain the habit of updating scripts frequently when using the system for future system recovery.
Advantages
This approach is more suitable for situations where you want to migrate existing systems to a later version. For example, when migrating Ubuntu 10.04 to 12.04, after formatting the system and reinstalling 12.04, the user can use this script to restore the appearance of the original computer. And due to the corresponding relationship between the software version in the Ubuntu source and the Ubuntu distribution version (for example, the firefox version in the 10.04 source may not be updated after a certain version), if 12.04 is still a relatively new LTS version, then you can guarantee that the software version installed with apt-get install on 12.04 is relatively new. At the same time, if most of your configuration recovery is done by restoring specific steps, you will have the opportunity to check whether these steps still apply to the new version of the software. It will not be applicable after restoring the configuration of the old version of the software from the cloud to the new version of the software. of course, in theory, this is not a big problem. Many famous software under Linux respect users' old habits very much and will not change the way they read configuration files easily. In most cases, restoring the configuration of the old software to the new version will not occur too much.
Shortcoming
Since the full backup method is not adopted, the shortcomings of this backup and recovery strategy are also obvious, although it can be guaranteed that the original appearance of the computer will not be lost after the upgrade, but relatively speaking, manually restoring the configuration of many software still requires considerable time and effort, even if the backup strategy is perfect. The author still spent a full 5 days of National Day holiday when upgrading Ubuntu 10.04 to 12.04 in this way. Therefore, I personally recommend that you only make such an upgrade when the version of LTS, which is released every two years, appears, so as to keep the computer in a brand new state.
Scripted recovery strategy; inherit / home partition data
The reason we mentioned a separate / home partition is that most of the user's important personalized configuration and data are stored in this directory, so that Ubuntu's official cloud backup software, Ubuntu One, assists users in backing up the data of the / home partition to the cloud by default. Therefore, if the data of this partition can be used when reinstalling the system, it will undoubtedly save us a lot of time for data recovery and configuration recovery, not to mention that some data, such as movies, photos may occupy hundreds of gigabytes of space, there is no independent / home partition, and users simply cannot accommodate big data's second medium for temporary backup when reinstalling the system and formatting the partition. Unless you have a second hard drive. On the other hand, when restoring the system, because the configuration and data are still in the / home directory, you only need to execute the script mentioned above to reinstall the software, without the need to manually restore the steps to configure the software.
In order to use this recovery strategy, when installing Ubuntu, you can refer to the partition recommendation of the previous blog to separate / home partition, and always ensure that only your important data and configuration are stored in this directory when using the system. If there must be some special cases, you must record them in the recovery script, and there are other backup measures in the cloud. As long as your / home partition is not damaged, the cost of recovery is relatively small. When reinstalling the system, you can format / directory mounted partition, but remember in the following Installation type interface do not choose to format / home the partition, otherwise you will not be able to use the data of this partition.
Advantages
Obviously, this strategy is economical, saves a lot of trouble, is a very common system recovery strategy, and is also suitable for restoring the original appearance of the computer after reinstalling a high version of Ubuntu, such as upgrading from 10.04LTS to 12.04LTS.
Shortcoming
After all, the data using the past / home partition retains the old configuration and directory structure as well. As mentioned earlier, although this will not be a big problem when matching the new version of the software, once something happens, such as the difference between the two software versions is too big, the new version cannot work properly on the old configuration or directory structure, and users should have the ability to solve the problem. You still need to restore the configuration steps manually by viewing the script comments.
Overall backup and recovery Strategy of tar package
The above two recovery strategies inevitably need to insert a boot USB disk or CD after the partition, install the operating system itself from scratch, and continue to install the software and restore the configuration after installing the operating system. Students familiar with the famous Ghost under Windows must be wondering whether there is such an one-stop backup scheme under Ubuntu: regardless of the current state of the computer system. I can back up every byte of the entire system, and when I need to restore the system, I can restore the original backup state to a new machine or formatted current machine, or even a virtual machine, without even installing Ubuntu itself. This is also the most common strategy used by the IT department of an average company when reinstalling machines for employees, for no other reason, just because it is the quickest way. It takes no more than an hour for a backup to restore a system.
Advantages
The quickest way to restore a backup is to restore your backup everywhere by burning the master disk. You can restore the backup from one physical machine to another physical machine or virtual machine, and you can even restore the backup from one virtual machine to another physical machine or another virtual machine, which is very flexible and convenient.
Shortcoming
One problem with this approach is that if the hardware configuration of the target machine that needs to be restored is too different from that of the source machine that makes the backup, some drivers may not work properly after recovery, such as the computer has no sound, or the graphics resolution is too low to connect to the Internet. At this time, users need to try to solve the problem on their own. The second problem is that due to full backup, it means that if you back up a 10.04 system, you can only restore to 10.04 system, and there is no way to upgrade your Ubuntu to a later version. The third problem: a certain cost of learning and practice, the following is my personal practical experience to provide the basic steps and principles of full backup of the tar package, maybe you can find a more convenient script or backup software to replace these tasks on the network, but if you encounter problems, returning to these specific steps and principles can help you understand what went wrong and how to solve these problems.
1. Full backup
Thanks to the powerful command line and system design of the Linux system, the basic principle of fully backing up a Ubuntu system is quite simple: use the tar command to package the necessary file directories, that is to say, there is no difference between backing up the system and backing up data.
Create a new script file, BACKUP_SYSTEM.sh, and add the following:
Mkdir ~ / BACKUP_SYSTEM sudo tar-- exclude / proc-- exclude / mnt-- exclude / tmp-- exclude / media-- exclude / home/jiawzhang/Downloads-- exclude / home/jiawzhang/Templates-- exclude'/ home/jiawzhang/VirtualBox VMs'-- exclude / home/jiawzhang/BACKUP_SYSTEM-jpcvf ~ / BACKUP_SYSTEM/Ubuntu-12.04-20121114-home-pc.tar.bz2 /
These two commands first create a new BACKUP_SYSTEM directory in the home directory to place the backed-up tar package. Then the-exclude parameter of the tar command excludes some directories that you don't think it is necessary to back up, such as the Download, Templates directory, and in my case, VirtualBox VMs is excluded, because after installing the virtual machine, the directory where Virtualbox is located will be extremely inflated, so there is no need to back up all dozens of gigabytes of virtual machine images into the tar package. -jpcvf this command: J means to use the bzip2 format to package, which is a compression time-consuming but high compression ratio format, often used to compress big data. P means to retain the user permission information of the directory structure when making the tar package, and protect the file system on the spot to a certain extent. Cvf means to create a compressed package and list the detailed compression process. ~ / BACKUP_SYSTEM/Ubuntu-12.04-20121114-home-pc.tar.bz2 specifies the file name of the package. I personally prefer to write down the version information, the packing time and the backup on which machine it is made in this file name, which is helpful for future recovery operations. The * of this command has a "/" character that means to make a full backup from the root directory of your machine, and everything on your computer will be typed into the final compressed package except the directory of-exclude. Even if it is a full backup, be sure to identify which directories do not need to be backed up beforehand, otherwise the compression and decompression process will become unacceptably long.
Open the terminal and run sh BACKUP_SYSTEM.sh to start the backup. Depending on the amount of data the user backs up and the quality of the hardware configuration, the duration of the backup will vary. On the author's local machine, it took about an hour to remove the full backup of unnecessary directories, compressing 40g of data into a 9G compressed package. If you want to know the progress of compression all the time, you can open another terminal and run the following command:
Watch-d-n 5 ls-alh ~ / BACKUP_SYSTEM/
This watch command is used to execute the subsequent'ls-alh ~ / BASHUP_SYSTEM/' every 5 seconds and highlight the difference between the two execution, so you can observe the change in the size of the compressed package in progress.
two。 Full recovery
The steps of restoring the system will be much more complicated than backing up. Here are the main steps, and I will try to explain the meaning of each step.
● ensures that the pre-backed up package is accessible in a partition, assuming that your backup package is located in / home/jiawzhang/BACKUP_SYSTEM/UBUNTU-2012-02-05.tar.bz2
● restarts the computer through Ubuntu's boot USB drive or CD-ROM to enter trial Ubuntu mode.
● opens the terminal in the Ubuntu in trial mode and runs the command
Sudo su-
Switch to root permission, and commands such as fdisk-l and df-h can only return accurate results after obtaining root permission.
● run command
Sudo gparted
Open the partition software gparted under Linux, and if prompted for installation, run
Sudo apt-get install gparted
After that, you can partition according to the partition recommendation of the previous blog, and if you are satisfied with your partition, you can also skip the partition step and just format / the partition. / home is located in the partition because it is used to store the backup package, so you can choose not to format it for the time being.
● decompresses the backup package
Mkdir / tmp/root mkdir / tmp/root2 mount / dev/sda1 / tmp/root mount / dev/sda2 / tmp/root2 cd / tmp/root2/jiawzhang/BACKUP_SYSTEM/ sudo tar-jpxvf UBUNTU-2012-02-05.tar.bz2-C / tmp/root
Booting to live Ubuntu mode with a flash drive will not actually mount your physical partition, so here you need to manually mount the / partition you just formatted and unzip the package and import it using the mount command. Create two new directories / tmp/root / tmp/root2 and mount the partition / dev/sda1 / dev/sda2 to these two directories. Make sure that sda1 is the partition of the mount / directory after the system recovery, and sda2 is the partition of the original / home directory, where the backup package we need exists. After mounting, / tmp/root corresponds to the sda1 partition, / tmp/root2 corresponds to the sda2 partition, and entering / tmp/root2/jiawzhang/BACKUP_SYSTEM is the location of our original backup storage. Run sudo tar-jpxvf xxx.tar.bz2-C / tmp/root to decompress. The x in jpxvf refers to decompression, and-C / tmp/root specifies the target directory to be decompressed. This is actually the root directory where the sda1 partition is located. Once this is done, all the data has been restored to the sda1 partition.
You should be able to see directories like / tmp/root/etc, / tmp/root/home/, which correspond to the original / etc, / home. The following steps specify that when booting the system, the sda1 partition is mounted back to the / directory, and the sda2 partition is mounted back to the / home directory, so that the directory structure of the system is fully restored. In addition, since the sda2 partition corresponding to the / home directory has not been formatted before, you can choose to delete all the data under / tmp/root2/jiawzhang/ except BACKUP_SYSTEM, and then run:
Cp / tmp/root/home/. / tmp/root2/-r rm / tmp/root/home-rf
Re-copy the / tmp/root/home part of the data just extracted from the backup package to / tmp/root2, and then delete / tmp/root/home, which completes the transfer of recovered home data from the sda1 partition to the sda2 partition: the sda2 partition is later used to mount the / home directory, and the data under the home should be restored to this partition.
● recovers the GRUB/MBR information of the partition
After formatting, partitioning and other steps, even if you restore your system on the existing hard disk, the uuid of the partition may have been changed, so the boot information backed up in the compressed backup package, such as: GRUB/MBR is no longer matched with the current actual information, so we have to do repair work.
Still running in live ubuntu mode:
$sudo add-apt-repository ppa:yannubuntu/boot-repair $sudo apt-get update $sudo apt-get install-y boot-repair $sudo boot-repair
Download and run the startup repair software boot-repair, and click on the default recommended method after startup. If you want to know exactly what the software has done, you can refer to the manual repair steps here. However, because the author has not verified its correctness, it can not be guaranteed to be available.
1$ ls-al / dev/disk/by-uuid
Check the uuid information of each partition again to make sure that these uuid are consistent with the uuid used in / tmp/root/etc/fstab, and the / and / home,swap that need to be mounted also match the corresponding uuid in / tmp/root/etc/fstab. Because the backup we restored uses the old uuid information, if it is inconsistent: manually open the / tmp/root/etc/fstab file to correct, the main job is to replace the uuid string in it and the same as in the above command. When booting the system, the / etc/fstab file specifies that the sda1 sda2 sda3 partition is mounted to /, / home,swap, respectively. If the correct uuid and partition directory mount match, the system will not boot correctly. You can take a look at the snippet of the / etc/fstab file:
# / was on / dev/sda1 during installation UUID=f381f8cd-ca11-4227-b9ce-8de330bf0e9f / ext4 errors=remount-ro 0 1 # / home was on / dev/sda2 during installation UUID=b4b376c7-9ef0-48dc-9f50-28decd899190 / home ext4 defaults 0 2 # swap was on / dev/sda3 during installation UUID=d770aa08-a3f3-4469-a682-f161cff16135 none swap sw 0 0
In addition, if you install the second hard disk, you can also use'ls-al / dev/disk/by-uuid' to check the uuid of the new hard disk, and create the corresponding mount directory of the hard disk partition, then write this information to / etc/fstab, so that the system will automatically load your new hard disk partition after boot.
● rebuilds the system directory
These are the directories we added after the-exclude parameter when we made the backup.
Mkdir / tmp/root/proc / tmp/root/mnt / tmp/root/tmp / tmp/root/media chmod 777 / tmp/root/tmp
Remember to give tmp/root/tmp 777. this is a temporary directory at the system level and requires full read and write permissions, otherwise your system will not be able to boot successfully. I almost gave up because I ignored this small detail when I first practiced full backup and recovery.
● restart the computer
Shut down the computer, and restart the computer from the hard disk, if all goes well, the full recovery has been successful, at this point, you can use the backup of the exclusive efficient system at that time.
The operation of full backup and recovery has a certain risk for beginners. If you are worried about data loss due to improper operation, you can first practice in the virtual machine environment. The author has practiced that this method is also applicable to virtual machines.
Migrate the wubi system to the physical partition
In addition, some users initially tried Ubuntu,*** on Windows through Wubi and decided to abandon Windows completely only to find that they had accumulated too much software and configuration in Wubi, and the cost of reinstalling the system was high. The author himself initially practiced Ubuntu in the Wubi system, and only a year and a half later did he officially migrate to an independent partition and bid farewell to Windows completely. So here's a brief introduction to how to port a Wubi system to a physical partition.
● New Partition
Use the partitioning tool under Windows to split two partitions from the existing partitions, assuming that they are called / dev/sda5 as the installation system and / dev/sda6 as the swap partition. (if you need a separate / home partition, you can have one more)
● enters Wubi system
● download and run the migration script
Click to download the Wubi migration script and unzip it to run.
Sudo zxvf wubi-move.tar.gz sudo bash wubi-move.sh / dev/sda5 / dev/sda6
If you have a separate / home partition, you can refer to the section above, which unzips the backup package and recovers / home partition data.
● restart the computer
If all goes well, the system will appear Grub boot menu, you can choose to enter the Windows or physical partition of the Ubuntu system, the content of this Ubuntu system is the same as your Wubi system.
The usage and update of this script is also ongoing and currently supports all versions from Ubuntu 8.04 to 12.04. Here are just some summaries, and readers can visit Ubuntu Forums to see more usage and other details of the script.
Ubuntu system upgrade strategy
Frequency
Ubuntu officially releases its own new version every six months, which is in fact a big burden for users. Often, it has not adapted to the current version, and the new version is pushed over again, so my personal opinion is that there is no need to catch up with the new, only upgrade the biennial version of LTS.
Timing
We also said before that the software version in a certain version source of Ubuntu will correspond to Ubuntu's own version. For example, the input method software iBus on Ubuntu10.04 will only be updated to version 1.2. if you want to use the 1.4 version of * *, you can either compile and install it yourself, or try to persuade software authors or other enthusiasts to package and update the iBus version in the Ubuntu10.04 source or find a third-party source, which is quite inconvenient. For a release that is too early, many software writers do not have the motivation and enthusiasm to develop, test, and update sources for compatibility. So when you find that the software in your distribution source is too old and there are more and more compatibility problems with each other, it is also a signal that you should upgrade your existing system. To take my own example, I decided to upgrade from 10.04 to 12.04 two months ago because there was a conflict between the 10.04 pinyin input method fcitx and the newer version of firefox, which always led to false death of the page. Asking the source Packer of fcitx was in vain: he didn't want to update the version of fcitx under 10.04 to solve this problem.
Mode
Although Ubuntu itself provides commands such as' sudo apt-get dist-upgrade' to do major upgrades between distributions, the effect is not satisfactory from some users' feedback, and there are always all kinds of problems in upgrading the system in this way. Therefore, it is recommended that readers can make cross-version upgrades with reference to the backup and recovery strategy mentioned in this article. In general, such upgrades will not have too many problems, unless the differences in some software are too great, and users can adapt themselves for a period of time.
On the Ubuntu system backup recovery upgrade strategy is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.