Common backup methods for Linux servers

Source: Internet
Author: User

System backup is a very important part of system management, this paper introduces the backup methods of various Linux systems in detail, and it is believed to be helpful to the daily management of our work.

Backup is an important task, but many people do not. Once the data is lost due to improper use, backup becomes a real lifesaver. This article discusses the policies for setting up backups and how to select Backup media, and describes the tar and Cpio tools for backup.

Set up a backup policy

Setting up backup policies and schedules can increase the likelihood of backups being made. Before the backup begins, determine what data is backed up, how often it is backed up, and what media to use for backup. When backing up, a full backup should be done.

Backups are usually scheduled to take place during idle time. In most systems, the number of open files is minimal because of the fewest numbers of users at this time. Because the backup consumes some system resources, the user will find the system unresponsive when running the backup.

If the Linux computer has only one user, you can back up the entire system for one weeks or one months. If you have critical files, you should have a plan to copy these files to a removable disk.

Before backing up, be sure to set up the backup device correctly. Most tape backup systems can be found to be correct when they are installed. After the system starts, open a terminal window and enter the following command: $dmeg less

Scroll through the list and look for the drive from your tape system. If it is not found, a component driver needs to be loaded.

If you run a Linux server, you need to make a backup plan, but that doesn't mean you need to back up everything every day. There are only a few things in the system that need to be backed up daily, and the following items are listed:

User files: The user files in the/home directory are backed up every day.

Profiles: Profiles in the/etc and/var directories do not require frequent backups and are backed up once per week or month, depending on how frequently configuration changes are made.

Program Files: The program files in the/USR and/opt directories are rarely changed and can be backed up after installation. Typically, program files can easily be recovered from the original installation disk.

Select Backup media

There are several options for where to save the backup. Here are some options for backup media:

Floppy: If you want to quickly back up important files or bring them home, the floppy disk is still an optional backup medium.

Disc Writer: As the disc writer becomes more reliable and the price is getting lower, the disc itself is very inexpensive. One advantage of this option is that the disc is not easily damaged and its backup is highly reliable. There are two disadvantages to using the disc writer: they are slower and can only hold about 650MB.

rewritable discs: rewritable optical drives are much more expensive than disc writers and work in a similar way. However, these discs can be rewritten, and it is much more expensive than a disc that can only be written once. Rewritable discs Other features are similar to the disc writer.

Jaz and Zip:zip drives are popular and have become a standard configuration for many PCs, while their disks and drives are inexpensive. It has a disk that can hold 100MB of data and is a good choice for fast, removable backups. Jaz disks can hold up to g bytes of data and use more advanced techniques for better performance. Jaz drives and Jaz disks are more expensive. Jaz and zip defects are both easy to damage and keep time relatively short.

Tape Drives: Tape backup devices are the standard configuration for most Linux servers. Tape is reliable, and there are few errors, which are almost as long as other media storage time. For Point-to-point workgroup networks and midsize networks, Travan and high-end digital audio tapes (DAT) are often the best choice. The Travan drive is compressed to handle 8GB data, which is sufficient for a small network with 5-10 PCs. DAT drives have better performance and can handle 24GB of data. DAT drives are more expensive than Travan drives, but their tape prices are cheaper than Travan QIC tape reels.

High-end tapes: Choosing high-end tapes can be quite expensive. This drive has greater capacity and higher speed than Travan or dat. The three widely used drive types are: Sony advanced intelliget Tape (AIT), Quantum Digital Linear Ta p E (DLT) and Exabyte Mammoth 8mm. They can hold at least 20GB of uncompressed data and have a higher data transfer capability.

Tar for backup

The Backup tool tar is a reliable way to back up files in the past, almost working in any environment, and Linux is generally trusted by older users. Files that end in. Tar in Linux are created with tar. It is used beyond mere backups and can be used to put many different files together to form an easy-to-separate file. Tar was started from the tape archiver Backup tool. The GNU tar tools included in Linux are easy to use, contain an option to compress, and support an increasing number of backups. Tar is a command-line tool with no graphical interface. Open a terminal window with Konsole or KVT, followed by a simple backup command: $tar CVF-Home >/temp/backup.tar

This command creates a Backup.tar file in the/tmp directory, all of which are included in the/home directory. You can then copy the tar file to the backup disk. When using a simple backup, if you want to use the compression function, change to the following command: $tar CZVF-Home >/tmp/backup.tgz

The extension above. Tgz indicates that this is a compressed file. The next example can be used to directly back up to an installed Jaz drive, but do this to make sure there is enough space:

$tar Czvf/mnt/jaz/backup.tgz-Home

For a tape drive, use the device name: $tar czvf/dev/st0/backup.tgz-Home

If you have a very large backup, you can use the multi-volume option. However, you cannot use compression in this way. When the first disk or tape is filled, tar prompts you to insert another one: $tar cvmf/dev/st0/5mar2000.tar-home

To restore a backup use the following command to Jaz disk as an example: $tar xzvf/mnt/jaz/5mar2000.tgz/home

Table 1 lists the main function parameters of tar. There are also a number of optional parameters that are not detailed in this article.

Table 1 The Backup tool tar can be set to run regularly based on time using the Crontab tool. For example, to back up the/home directory to a SCSI tape drive every 2 o'clock in the evening, simply add the following statement to the root crontab: * * * * tar Cvf/dev/st0/homefiles.tar-Home

Cpio for backup

The GNU cpio tool starts the program from the command prompt, just like tar. Cpio is more complex than tar, but more reliable. Because if there is a bad block somewhere in a tar file, you cannot access other parts of the backup file, and with Cpio, only the bad block cannot be accessed. Cpio creates a backup called Copy-out mode, and the backup archive contains information such as file and owner, time, and access permissions. Cpio requires a list of files that are assumed 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 files being archived. For example, the following command archives All files that have been modified within the previous 2 4 hours: $find/home-mtime 1-type f-print cpio-o >/dev/st0

Copy-in mode to extract files from the backup archive. The following command restores all the files in the first two backup examples: $cpio-i </dev/st0

You can also schedule a backup of Cpio and use the Crontab tool to run it regularly based on any time. For example, to back up the home directory to a SCSI tape drive every 2 o'clock in the evening, add the following statement to the root crontab file: * * * * 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.