Backup and recovery on Linux servers

Source: Internet
Author: User
Article Title: backup and recovery on 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 categories for general backup should be the highest priority for responsible system managers. Although Linux is a highly reliable operating system, system failure may still occur. It may be caused by hardware failure, power interruption, or other unexpected problems.

More often, these problems come from human errors, improper changes, and even the deletion of important files. If you are responsible for managing users in the system, you may often be asked to recreate files accidentally deleted.

If you perform a general backup, the daily basis is good (at least for more frequently-active user files), you will help reduce the loss of files and increase the degree of recovery.

The safest backup method is to record them in different media, such as tape, removable hard drive, writable cd. Then, separate your backup and your Linux system. Sometimes this may not be practical-maybe there is no fire room where you can store the backup tape! Or there is no way to access such an external backup system at the top priority. Even so, the backup can still be performed, but it will be limited.

In my service organization, I back up data on Several Linux systems. Depending on the situation, some backups are stored on tape, others are written to different servers on the network, but some still use cron automatic jobs (probably because the server is at the remote end, it is impractical or impossible to back up tapes on a daily basis) and simply put them in separate partitions on different disks (for example, in the ''/archive/'' File System ).

At home, I don't have an external backup system, and I don't have a lot of disk space to store backup image files. Therefore, I only back up my User Files in ''/home/'', and there are also some custom configuration files in ''/etc, store backups in different disk partitions.

Server backup program

There are several different methods for Linux backup, including the command column tools available in all Linux releases, such as ''dd'' and ''dump '', ''cpio ''and ''tar ''. Other text tools, such as ''amanda ''and ''taper'', are designed to add user-friendly user interfaces during Backup and storage. Of course, there are also graphical interface tools, such as ''kdat ''. Finally, there are commercial backup tools like ''bru'' and ''fectbackup + ''. Any of these backup plans is sufficient to provide protection for your valuable data.

Here is a list of some including where to get the tool, which can be found in "Linux Applications and Utilities Page", in http://www.xnet.com /~ Blatura/linapp2.html # back. When determining the backup mode, consider the following factors:

Portability-is the portability of backup important to you (that is, when a Linux release or Unix backup is applied and then saved to another one; for example, from Solaris to Red Hat Linux? If yes, you may want to select a command column tool (that is. ''dd'', ''dump '', ''cpio'', or ''tar ''), because you can fairly determine that this tool can be found on another * nix system.

Unattended or automatic backup-the ability to perform regular and automatic backup without human intervention is important to you? If yes, you may need tools that support this solution and backup media.

User Friendliness-is it important for users to be friendly? If yes, you may want to select a tool for text or graphic interfaces. Commercial applications provide the simplest interface and technical support.

Remote Backup-is it important for you to back up and store data from a remote machine? If yes, you may want to select a tool in the Command column or text mode instead of a graphical interface (unless you have fast network connections and the ability to execute remote X sessions ).

Network Backup-is it important for you to back up and store data from a web host? If yes, you may need some command column tools (such as ''tar '') that support access to backup devices from the network ''), or dedicated tool programs such as ''amanda ''or some commercial tool programs.

Media type-Backup can be stored in many different media, such as tape, external hard drive, ZIP disk, or read/write CD. Consider the price and reliability, storage capacity, and transmission speed.

Warning do not include the ''/proc' pseudo file system when backing up your system! The file in/proc is not a real file, but only a description that looks like a file and points to the link of the core data structure. Back up ''/proc/kcore'. In fact, this is a disguised file that contains all the data in the memory and will waste a lot of tape! You may also need to avoid backing up the ''/mnt'' file system unless you have special requirements for backing up from a CD-ROM, a drive, a shared file online, or other installation device.

Obviously, the backup and storage process varies depending on the backup method you selected. However, in this section, I will discuss the two most commonly used tool backup methods: 'tar ''(whose name is derived from" Tape ARchiver "), this is a command-column tool with high portability in * nix systems, and ''kdat'', a tape backup tool from the graphic interface of KDE suite.

Finally, I should add that, based on the backup method you selected, you can still use the cron function to perform automatic backup even if the tool is not built on the automatic backup schedule. For details about using Cron and Crontab files for automatic jobs, and how to create a crontab table file.

Use ''tar ''for backup: If you select ''tar'' as your backup solution, you may need to take some time to learn about various command options; type "man tar" for more details. You also need to know how to access the appropriate backup media; Although treating all devices in the Unix world is like processing files, if you write to a character device like a tape, the file name is the name of the device (that is. ''/dev/nst0'' is a tape drive on the SCSI interface ).

The following command backs up your entire Linux system to the ''/archive/'' file system, except for the ''/proc/'' disguised file system, ''/mnt/'', ''/archive/'' File System (there is no need to back up our backup file !), There is also a large Squid cache file (yes, in my opinion, it is a waste of backup media and does not need to be backed up) of any mounted file system:

Tar-zcvpf/archive/full-backup-'date 'your d-0000b-policy''.tar.gz

-- Directory/-- exclude = mnt -- exclude = proc -- exclude = var/spool/squid.

Don't be scared by the above commands! When we divide it into two parts, you will find the beauty of this powerful tool.

The preceding command specifies the ''z'' (compression; backup data is compressed by ''gzip '') and ''c' (creation; an archive file is created), ''v'' (verbose; displays the backed up files), and ''p' (can be saved; the protected information will be "remembered" and can be replied ). ''F'' is the name of the archive file (or device) to be written, enclose the ''date' command with two backquotes. The general naming convention is to add ''To the backend of an uncompressed file ''. tar '', the compressed file with the ''tar.gz ''' -- directory ''option tells tar to jump to the following file path (in this example, the '/' directory) before starting the backup ). The '-- exclude' option instructs tar not to back up the specified file or directory. The '.' symbol tells tar to back up everything in the current directory.

Note: It is important to know that the tar options are case-insensitive! In addition, most of the options can be simplified with the mnemonic (I .e.. ''f''), or the full name of the option that is easier to remember (I .e.. ''file ''). A ''-'' character is used as the beginning of the letter to identify the Enis. There are two headers of the symbol before the full name. Refer to the man page for more information about using tar.

In another example, only the specified file system (the same as the previous example of writing all data except the previous one) is written to a SCSI tape drive: tar-cvpf/dev/nst0 -- label = "Backup set created on 'date' + % d-% B-% Y ''. "-- directory/-- exclude = var/spool/etc home usr/local var/spool

Note that the ''z'' (compression) option is not used in the preceding row. I strongly recommend against writing compressed data to tape because if some of the data on the tape is damaged, you will lose the entire backup! However, uncompressed archive files are highly recoverable even if some files on the tape are damaged.

Because the tape drive is a character device, there is no way to specify a real file name. Therefore, the file name specified for tar can be simplified to the device name, ''/dev/nst0'', which is the first tape device on the SCSI sink.

Note: The ''/dev/nst0'' device does not bring back after the backup is completed. Therefore, several groups of backups may be written to the same tape. (You can also select the ''/dev/st0'' device. In this case, the tape will be automatically carried back after backup)

Since we cannot specify the file name for a backup set, the '-- label'' option can be used to write information about the backup set.

In the end, it is only contained in ''/etc/'', ''/home/'', ''/usr/local '', and ''/var/spool/'' (except the Squid cache file) will be written into the tape.

When using a tape, you can use the following command to return the tape and exit the tape:

Mt-f/dev/nst0 rewind

Mt-f/dev/nst0 offline

Tip: you will find that when the archive file is created, the '/' (diagonal line) symbol in front will be removed by tar. This is tar's default operation mode, which is intentionally used to protect you from overwriting the original versions of these important files, in case you accidentally overwrite incorrect files during the reconstruction process.

If you really don't like this feature (Remember, it's a feature !) You can specify the tar ''-- absolute-paths'' option to retain the front slash. However, I do not recommend this because it is dangerous!

Back up with ''kdat '': if you use the KDE Desktop environment, I believe you will find that the ''kdat'' utility is not only powerful but also friendly to users. In addition, KDat uses ''tar ''as its backup engine. Therefore, the backup group written with KDat can be read not only with KDat, but also with tar! This makes KDat a good choice for user friendliness and backup portability.

TIPS: Even if you decide not to use the KDE suite, you can still use KDE if you have installed the Qt library.

When you run KDat for the first time, you need to create a backup profile. This profile tells KDat which files in the system you want to back up. If you want to, you can create several Backup profiles according to your needs (for example, you can create a profile called "Full Backup" for Full Backup of the system, or "Quick Backup" only backs up user files ).

To Create a Backup profile, select Create Backup Profile from the "File" option in the menu bar or right-click the Backup profile folder, then select "Create Backup Profile "). On the right hand side of the KDat window, you can change various settings, such as profile name, archive name, tar option, and others. Click the "Help" menu for instructions on the usage of these settings.

 

[1] [2] Next page

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.