Set backup for LINUX

Source: Internet
Author: User
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. You can add backup policies to set backup policies and plans.

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 are backed up in the/home directory every day.

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.

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:

If you want to quickly back up important files on a floppy disk or take them to your home, the floppy disk is still an optional backup medium.

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.

A rewritable CD drive is much more expensive than a CD 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 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 backup devices are 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 tapes may be 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

Tar is a reliable method for backing up files in the past and can work in almost any environment. Linux users generally trust it.

Files ending with .tar in linuxare all 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 tar main function parameters
Parameter description
-A is appended to the end of another tar archive.
-C create a new tar archive
-D identifies the differences between the tar archive and the file for verification of a document
-- Delete: delete files from the archive. disk backup is not optional.
-R: append the file to the end of the tar archive.
-T list the contents of the tar archive
-U only attaches new files in the tar document to the archive.
-X unlocks a tar archive

You can use the crontab tool to set tar backup to run regularly based on time. 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 the 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

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: 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.