Linux backup policy (version 2)
Backup policy backup ideas
I. potential threats to the System
? System hardware faults
? Software faults
? Power Supply Fault
? User misoperations
? Man-made destruction
? The content in the cache is not written to the disk in time.
? Natural disasters
Ii. Selection of backup media
Backup media: Hard Disks [commonly used by Linux File Servers] tape [commonly used] removable storage devices
Generally, when selecting backup media, you must weigh the reliability, speed, and price. Generally, choose hard disks and tape drives.
Iii. Backup Policy
? Full backup
Perform a full backup of the system at intervals. In this way, once a system failure causes data loss, you can use a backup to recover data to the last backup.
? Incremental Backup
A full backup is performed first, and then a backup is performed at intervals of a short period of time, but only the changes in each short period of time are backed up.
In practice, the two are used in combination.
Iv. Backup Classification
? System Backup
Back up operating systems and applications
Objective: To quickly and completely recover system operation after system crash
It mainly backs up/etc,/boot,/var/log,/usr/local, and so on. Generally, it is performed only when the system content changes.
? User backup
Implements the backup/home of user files, and frequent changes to user data
Generally, Incremental backup is used.
5. record changes and create backup logs
Record System Changes: record the detailed descriptions of system changes and the reasons for the changes
Create backup log: use the backup log table
Secure
[Example of a backup log table]
Machine name, IP address, storage location
Backup time
Backup media and ID
Backup File System
Backup directories and files
Backup Command Used
Backup personnel and others
Instance analysis
I. cp command backup example
Cp-Rpu [Backup Directory] [target directory]
-R backs up directories.
-P: Keep the Backup Directory attributes.
-U Incremental Backup
Remote Backup: scp
E. g.
Cp/etc/inittab/backup/inittab_2014092301.bak # the last two digits indicate the number of modifications made on the current day, but the time value of the source file and backup file is inconsistent.
Cp-Rup/etc // backup/etc_2014092301.bak
Ii. Example of tar command backup [SAVING file attributes by default]
Backup
1. tar-zcf/backup/sys_20110303.tar.gz/etc/boot # Back Up The/etc and/boot directories. You can package multiple directories at the same time.
2. tar-zcf backup_user_20110303.tar.gz/etc/passwd/etc/shadow/etc/group/etc/gshadow # back up the specified files in the/etc directory
3. tar-ztf backup_user_20110303.tar.gz # Check the files in the backup package if you do not understand the package.
Restore
1. tar-zxf/backup/etc_20110303.tar.gz # restore the/etc directory to the package file source directory by default.-C can specify the Restore directory.
Tar-zxvf backup_user_2014092101.tar.gz-C/backup
2. tar-zxf backup_user_20110303.tar.gz etc/group # only restore the specified file in the backup
# Create the etc directory in the current directory and restore the group file to the directory. Note that there is no/symbol before the etc directory. How do I write the files in the tar package, what is recovery!
Backup Best Practices
1. tar-rf backup_user_20110303.tar/etc/default/useradd/etc/login. defs
Add the content of/etc/default/useradd and/etc/login.defsto backup_user_20110303.tar.
2. tar-uf backup_user_20110303.tar/etc/passwd
Append the modified content in the/etc/passwd directory to the backup file.
[*-R and-u options can only be used for tar packages and cannot be used to compress files]
3. tar-zcf/backup/etc _ $ (date ready before f).tar.gz/etc
Add time (year, month, and day) for backup file name)
4. tar-zcf/backup/etc _ $ (date + % Y. % m. % d-% H: 1_m1_.tar.gz/etc
Add year. Month. Day-hour: minute
Backup Process
1. Backup awareness
2. backup partition ro or unmount
Mount-o remount, ro/backup # mount the partition in read-only mode
Umont/backup # unmount the backup partition directly
3. Data Compression
4. Verify md5sum-c
5. gnupg2 asymmetric key encryption