Linux system backup

Source: Internet
Author: User
Linux has the biggest advantage over Windows: the installation process of Linux only involves the process of copying files and not writing the registry. therefore

Linux has the biggest advantage over Windows: the installation process of Linux only involves the process of copying files and not writing the registry. therefore, after the Linux system is reinstalled, you only need to back up the program files of the previous system and put them in the new system.

How to back up depends on how Linux is used and the purpose of your backup!

This is how I use Linux

Most user applications are installed under/usr/local by default. In addition, I will install some software under/opt/. Therefore, I need to back up both directories.

Almost all configuration files in Linux are stored in the/etc directory and need to be backed up.

I will store other things in the home user directory. Therefore, it is OK to back up the/home directory!

If you still use the database, some directories of var, such as lib, may also need to be backed up. if the kernel is updated, the/boot directory can also be backed up, but the impact is not big.

My purpose

After you reinstall the system, you can avoid the trouble of configuring vim and installing software! You only need to update the system! I am not a professional. Therefore, if you maintain a Linux database, your backup will never end with this.

1. back up user programs

The/usr/local directory is the installation location of common user programs,

tar -zcpPvf local.tar.gz /usr/local/

/Opt is also used to store user programs,

tar -zcpPvf opt.tar.gz /opt/
2. back up the global parameter configuration file

In Linux, most configurations are saved in the/etc/folder,

tar -zcpPvf etc.tar.gz /etc/
3. backup user directory
tar -zcpPvf monkeyzx.tar.gz /home/monkeyzx/ 

Here, monkeyzx is your user name.

4. Restore Backup

The backup recovery method is simple. you only need to extract the compressed package to the new system. Because the absolute path is used for compression, the following command can be used in any directory for decompression,

su roottar -zxpPvf local.tar.gztar -zxpPvf opt.tar.gz tar -zxpPvf etc.tar.gztar -zxpPvf monkeyzx.tar.gz
5. vim configuration

I packed my vim configuration into a package for the convenience of porting the previous configuration after the system is updated. the configuration file is placed on Github:

Https://github.com/xiahouzuoxin/vim_config

Tar command explanation

-Z gzip compression format

-X tar unpack

-C tar package and create a file

-P reserved file permission attributes (lowercase characters)

-P retains the absolute path. In Linux, to prevent files in '/' from being overwritten when extracting the tar package, the root "/" in the absolute path will be removed by default and can be retained with-P.

-V: Display compression information

-F: specify the package file name.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.