Backup is very important. Backup can minimize the loss. However, the backup in Linux makes a beginner feel that it is not as simple as in Windows. In fact, once you go deep, you will find that the backup in Linux is quite flexible. As long as you are familiar with it, you can configure the backup suitable for you. In addition, because backups generally occupy system resources, they are all carried out late at night. Therefore, they must be done in conjunction with scripts and plans. There is no backup script written here, and various backup scripts will be released next time.
I. Backup Data:
1. Host System
Files related to account and system settings.
/Etc/entire directory # because the host information parameter files are under/etc
/Home: the entire directory # The main directory of each person is shown below
/Var/spoool/mail
/Root
Optional:/boot # When the kernel is changed
/Usr/local or/opt # install other suites on your own
2. Network Server
Note: There are two ways to install the network service software: the system's own installation, the file is usually under/etc; The self-installation is generally under/usr/local, of course, you can also change the location of the installation on your own for specific applications.
/Etc/entire directory/usr/local/entire directory # data setting file
Assume that the server is WWW + MySQL:
/Var/www entire directory
/Srv/www entire directory
/Var/lib/mysql # service-related files in one sentence
3. directories that do not need to be backed up
/Dev
/Proc
/Mnt
/Tmp
That is to say, other directories can be selected for backup.
Ii. Backup tools
Command column tools, such as ''dd'', ''dump '', ''cpio'', and ''tar''
Text type tools, such as ''amanda ''and ''taper''
Graphical interface tools, such as ''kdat''
Commercial backup tools, such as ''bru'' and ''fectbackup +''
1. cpio is used for full backup. It works with the Find command and works with another hard disk that is completely used for backup.
Format:
# Find/-print | cpio-covB>/dev/st0 # Back up to the tape drive # cpio-iduv </dev/st0 # restore |
2. dd is used for full backup. Features: backs up a exactly identical hard disk.
Format:
#dd if=/dev/hda of=/dev/hdb |
3. tar is used for full backup and partial backup
Format:
# Tar-zcvpf/archive/full-backup-'date 'your d-0000b-policy''.tar.gz -- Directory/-- exclude = mnt -- exclude = proc -- Exclude = var/spool/squid. # complete backup |
Z compression. The backup data is compressed by ''gzip)
C. An archive file is created)
V verbose; displays the backed up files)
P allows storage; the protected data will be "Memorized" and can be replied)
F file) The option is followed by the archive file or device to be written.) note how the file name containing the information is obtained, enclose the ''date' command with two backquotes. The general naming convention is to add '. tar' to the backend of an uncompressed file and ''tar.gz 'to the compressed file''
The -- directory option tells tar to jump to the following file path before starting the backup, which is the '/' directory in this example ).
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.
# Tar-zxvf host. tgz # restoration # tar-zpcvf mysql. 'date + % Y-% m-% d '. tgz/var/lib/mysql # partial backup # tar-N '2017/17'-zpcvf home. tgz/home # Back Up Files after 2007/4/17 |
Iii. Backup method:This section is taken from IXPUB)
Consider the following factors:
Portability
-Backup Portability. Is it important for you to back up data from a Linux release or Unix application to another one, for example, from Solaris to Red Hat Linux? If yes, you may want to select a command column tool. ''Dd'', ''dump '', ''cpio'', or ''tar ''), because you can fairly determine that this tool can be found on another * nix system.
Unattended or automatic backup
-Is it important for you to perform regular and automatic backup without human intervention? If yes, you may need tools that support this solution and backup media.
USER FRIENDLY
-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 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 network hosts? If yes, you may need command column tools that support access to backup devices from the network, such as 'tar ''), 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.
Related Articles]
- Linux Command Summary-common system backup commands
- How to configure Linux Security Service Management