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,CPIO,DUMP,DD tools for backup. and the writing application of the script.
Set up a backup policy
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.
Items that need to be backed up:
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.
Backup method:
a
,
for the backup
Tar
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 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
Two for the backup
Cpio
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 plan the 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
Backup:
Find/home/odm/soft/qt5.2.0-print | Cpio-covb >/tmp/st0
Restores:
Cpio-icduv </tmp/st0
Three Dump for backup