Common backup methods for Linux servers

Source: Internet
Author: User
Article Title: Common backup methods for Linux servers. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems, open-source and other basic classification system backup is a very important part of system management, this article describes in detail the backup methods of various Linux systems. I believe this will be helpful for your daily management work.
 
Backup is an important task, but many people do not. Once data is lost due to improper use, backup becomes a real life-saving person. This article will discuss how to set backup policies and how to select backup media, and introduce tar and cpio tools for backup.
 
Set backup policy
 
Setting backup policies and schedules increases the possibility of backup. Before the backup starts, determine the data to be backed up, the backup frequency, and the media used for backup. Full backup should be performed during Backup.
 
Backup is usually scheduled in idle time. In most systems, the minimum number of users is allowed, and the minimum number of files is allowed. Because the backup takes up some system resources, the user will find the system slow response when running the backup.
 
If a Linux computer has only one user, you can back up the entire system once a week or month. If there are critical files, they should be systematically copied to a removable disk.
 
Before backup, make sure that the backup device is correctly set. Most tape backup systems can be correctly installed. After the system starts, open a terminal window and enter the following command: $ dmeg less
 
Scroll through the list and find the driver for your tape system. If no driver is found, a component driver needs to be loaded.
 
If a Linux server is running, a backup plan is required, but this does not mean that everything is backed up every day. There are only a few items in the system that need to be backed up every day. The items to be backed up are listed below:
 
User Files: User Files in the/home directory are backed up every day.
 
Configuration File: the configuration files in the/etc and/var directories do not need to be backed up frequently. You can back up the files once a week or every month, depending on the frequency of configuration changes.
 
Program Files: The program files in the/usr and/opt directories rarely change. After installation, make a backup. Generally, program files can be easily recovered from the original installation disk.
 
  Select backup media
 

There are multiple options for storing backups. The following describes some optional backup media:
 
Floppy Disk: If you want to quickly back up important files or take them to your home, the floppy disk is still an optional backup medium.
 
Disc writer: As the disc writer becomes more reliable, the price is getting lower, and the disc itself is also very cheap. One advantage of this option is that the disc is not easily damaged and its backup reliability is high. There are two disadvantages to using the CD Writer: they are slow and can only be saved about 650 MB.
 
Rewritable disc: the rewritable disc drive is much more expensive than the disc writer and works in a similar way. However, these discs can be rewritten, and they are much more expensive than only one write. Other features of the rewritable disc are similar to those of the disc writer.
 
Jaz and Zip: Zip drives are popular and have become the standard configuration for many PCs, and their disks and drives are not expensive. One disk can hold MB of data, which is a good choice for fast and removable backup. The Jaz disk can accommodate GB of data and use more advanced technologies for better performance. The Jaz drive and the Jaz disk are both expensive. Both Jaz and Zip are prone to damage and the retention time is relatively short.
 
Tape drive: the tape backup device is the standard configuration for most Linux servers. Tape is reliable and rarely produces errors. It takes almost a longer time to store than other media. For point-to-point workgroup networks and medium-sized networks, Travan and high-end digital audio tapes (DAT) are usually the best choice. The compression of the Travan drive can process 8 GB of data, which is sufficient for a small network with 5-10 PCs. The DAT drive delivers better performance and can process 24 GB of data. The DAT drive is more expensive than the Travan drive, but its tape is cheaper than the Travan QIC Tape Volume.
 
High-end tape: the choice of high-end tape may be quite expensive. Compared with Travan or DAT, this type of drive has a larger capacity and a higher speed. Three widely used drive types are Sony Advanced Intelliget Tape (AIT), Quantum Digital Linear Ta p e (DLT), and Exabyte Mammoth 8mm. they can contain at least 20 GB of non-compressed data and have higher data transmission capabilities.
 
Tar used for backup
 
The backup tool Tar is a reliable method for backing up files in the past and can work in almost any environment. Linux users generally trust it. In Linux. All files ending with tar are created with tar. It is used beyond simple backup and can be used to put many different files together to form a file that is easy to separate. Tar started from the Tape ARchiver backup tool. The GNU tar tool included in Linux is easy to use and contains an option for compression and supports increasing backups. Tar is a command line tool without a graphical interface. Use Konsole or Kvt to open a terminal window, followed by a simple BACKUP command: $ tar cvf-/home>/temp/backup.tar
 
This command creates a backup.tar file in the/tmpdirectory and contains all the content in the/home directory. Next, copy the tar file to the backup disk. When using simple backup, if you want to use the compression function, change it to the following command: $ tar czvf-/home>/tmp/backup. tgz
 
The above extension. Tgz indicates that this is a compressed file. The next example can be used to back up data directly to an installed Jaz drive. However, to do so, make sure there is sufficient space:
 
$ Tar czvf/mnt/jaz/backup. tgz-/home
 
For a tape drive, use the device name $ tar czvf/dev/st0/backup. tgz-/home
 
If there is a large backup, you can use the multi-volume option. However, compression cannot be used in this case. When the first disk or tape is filled up, tar will prompt you to insert another one: $ tar cvMf/dev/st0/5mar2000.tar-home
 
Use the following command to restore the backup: $ tar xzvf/mnt/Jaz/5mar2000. tgz/home
 
Table 1 lists the main tar function parameters. There are also many optional parameters, which are not described in this article.
 
Table 1 backup tool tar can be set to run regularly based on time with the crontab tool. For example, to back up the/home directory to the SCSI tape drive at every night, you just need to add the following statement to the root crontab: 00 02 *** tar cvf/dev/st0/homefiles.tar-/home
 
  Cpio used for backup
 
The GNU cpio tool starts the program from the command prompt line like tar. Cpio is more complex than tar, but also more reliable. Because if a tar file has a bad block somewhere, you cannot access other parts of the backup file, but cpio is used, only bad blocks cannot be accessed. Cpio creates a backup called copy-out mode. The backup archive contains information such as the file and owner, time, and access permission. Cpio requires a list of files to be backed up. One of the most convenient ways to create a list is to use the ls command. For example, to back up the/home directory to a SCSI tape device, enter the following command: $ ls/home cpio-o>/dev/st0
 
You can also use the find command. It includes many options that can be used to reduce the number of archived files. For example, the following command archives all files modified in the last two or four hours: $ find/home-mtime 1-type f-print cpio-o>/dev/st0
 
In copy-in mode, the file is extracted from the backup file. The following command restores all files in the first two backup examples: $ cpio-I </dev/st0
 
You can also plan the cpio backup and use the crontab tool to set it to run regularly at any time. For example, to back up the/home directory to the SCSI tape drive at every night, add the following statement to the root crontab file: 00 02 *** ls/home cpio-o>/dev/st0
 

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.