Backup and restoration skills for Linux servers

Source: Internet
Author: User

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'' (archive) specifies the archive file (or device) name 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.


To specify which files should be included in your backup profile, click the icon next to the '/' directory folder and click the left button. This will ensure that all files and everything in this directory will be backed up. Then, click the ''+ ''symbol next to the folder and open the folder to display the files and the following directories. You can exclude the files you do not want to back up. Just click the check symbol next to each file or directory you want to exclude and leave the key. For example, a full backup should contain all the files and directories that have been marked. Exclude ''/proc' (a disguised file system that contains information about your current operating system ), ''/mnt'' (directory, player, network share, often mounted under the CD-ROM), and if you are a Squid user, ''/ var/spool/squid'' (the cache file of squid ). Once you have selected the appropriate file, click the left button on the backup profile you have created, then, click the "Files>" button to move the selected file to your backup profile. [# Page _ #] [# page _ #]

NOTE: If your server data is too large to be actually stored in tape, you need to create separate backup profiles, each part of the backup group is one.


During the actual backup, put the Tape in and select "Mount Tape" from the "File" menu (or use a mouse to tap the icon that looks like a Tape ).


This will "mount" the tape (in fact, because the tape drive is a character device, in fact it cannot be mounted-in fact, KDat is just a first back-to-band, trying to read the starting information, if successful, search for indexes on the tape drive. Otherwise, KDat will remind you to format the tape.


(Note: If KDat continuously shows that there is no tape on the tape drive, but in fact there is one, you should ensure that the name specified in the parameter is correct, in the menu bar, tap the "Edit" option and select "User Preferences ".)


Once the KDat has been attached to the tape, you must select the backup profile before starting the backup. When you plan to start Backup, right-click the Backup profile you want, and then click "Backup. KDat will display a dialog box to show you the details about the selected backup profile. Click "OK" to start the backup.


When the backup starts, KDat displays a dialog box with various status information (after time, backup size, backup ratio, estimated remaining time, number of files, and total number of bytes written ), and the list of backed up files. A full backup that contains several gigabyte data may take several hours. If necessary, you can click the "Abort" button to discard the backup at any time during the backup process.


Once the backup is complete, you can select "Edit" in the menu bar, and then select "Unmount Tape" to Unmount the Tape, or click on the Tape icon, in this way, the tape will be taken back and then jumped out.


Undoubtedly, the more important thing about proportional backup is that when a problem occurs, it can make the important files reply normally! ()

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.