Linux backup and recovery

Source: Internet
Author: User
For any computer user, data may be lost due to sudden system failures or sudden power outages during normal operation. We always regret failing to back up the system and various files in time. In fact, a computer user often focuses on... information & nbs.

For any computer user, data may be lost due to sudden system failures or sudden power outages during normal operation. We always regret failing to back up the system and various files in time. In fact, it is a good habit for a computer user to back up important files. Regular system backup can minimize unexpected losses.

Linux users will also encounter related problems. now let's look at how to implement backup and recovery in linux.
First, we should understand that backups are classified into different levels. We may be able to back up the files modified yesterday or the files in the past week. of course, we will also back up all the files in the entire system. Different backup levels involve different storage media and the time required for backup.

For general files, the simplest backup is to use tools such as tar or gzip to package the files and store them in a floppy disk or tape. It is troublesome to selectively back up files or let the system automatically complete this task. In general, restoring a file is more difficult than backing up a file.

For the entire system, backup is often not necessary because the cd-rom and boot disk of the system are already relatively good backups, however, restoring the system often wastes some time. Of course, for new users, reinstalling the system is the easiest way to restore the system.

When archiving files in the simplest way, we are concerned about which files need to be archived. It is unnecessary to back up all the files. most of the system files are completely stored in the installation cd-rom or the installation disk, and we do not need to back up the files. However, in general, the user will change the file in the/etc or/usr directory. The/etc directory contains many system files, including our network settings, device management, and other system files. Once we have changed the system file, we should back up the relevant file immediately. The content in the/usr directory is mostly some of your own programs or files. it is best to back up the files before shutdown. For beginners, the contents in these two directories are closely related to daily work. we should pay special attention to them. If you have been using linux for some time, you may compile the system kernel or use a mailbox in linux, we need to back up the files in/usr/src/linux and/var/spool/mail. For example, if we want to put files in the/usr/src and/home/cchong directories into a floppy disk, we can use the following command: tar cvMf/dev/fd0/usr/src/home/cchong. The M parameter allows you to create multi-volume file storage. after a floppy disk is read, you are prompted to insert another one. Of course, you must mark it yourself.

To read the backup file, run tar xvf/dev/fd0 to open the package again.
If you do not want to always back up all the files, but want to back up the files that have changed the content, you can use incremental backup. Tools for creating incremental backup include tar and gzip, but they are not used independently.
First, you must generate a directory list of the files that have been changed in the past period, that is, find the files that have changed in the past period of time. Here you need to use a command: find the specific format can be:
Find/(specify the start Directory of the search, starting from the root directory)-mtime-7-print>/home/cchong/update. week
-Mtime-7 is used to process files in the past week. you can also change 7 to another number.
-Pint>/home/cchong/update. week stores the changed information in the specified file.
Next we can use the tar command: Tar-cv-M-T/home/cchong/update. the-T parameter in the command line week-f/dev/fd0 specifies the corresponding file.
Although the above method is simple, it still takes some time and we can find a better method.

Author: "Daily Yunhui"

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.