Linux Learning notes (Linux)

Source: Internet
Author: User

1. Backup overview

Linux systems need to back up data and/root,/home,/var/spool/mail,/etc and other directories such as logs.

The data for the installation service needs to be backed up, such as the data that Apache needs to back up, the configuration file, the Web page home directory, the log file, the source package installed MySQL needs backup/usr/local/mysql/data,rpm package installed MySQL needs to backup/var/lib/mysql.

(1) Backup policy

full backup : means to back up all the data that needs to be backed up, and of course a full backup can back up the entire disk, the entire partition, or a specific directory. Feature backups are slow and occupy a large amount of space.

Incremental backup : Each backup backs up only the newly added data, compared to the data that was last backed up. Features: Data recovery is more troublesome.

differential backup : The tradeoff between the first two is that, unlike incremental backups, the second backup is compared to a full backup for the first time.

2. Backup commands

(1) Dump command

The format is:

Dump [option] File name original file or directory after backup

Where the-level option is what we call 0-9 10 backup levels; the-F file name option specifies the file name after the backup, and the-u option indicates that the backup time is recorded in the/etc/dumpdates file after the backup is successful; the-v option shows more output information during the backup process The-J option means to call the Bzlib library to compress the backup file, in fact, to compress the backup file into. bz2 format; the-w option shows the backup level and the backup time of the partition being dump .

Example 1: Backing up a partition

# Backup command. Perform a full backup first, and compress and update the backup time [email protected]~]# dump-0uj-f/root/boot.bak.bz2/boot/...... Dump:wrote 22370kB uncompressed, 20288kB compressed,1.103:1Dump:dump is done# view backup time file [[email protected]~]#Cat/etc/dumpdates/dev/sda10Sun -  .: Wu: the  -+0800/dev/sda11Tue4  Geneva: -: in  -+0800#复制日志文件到boot分区 [[email protected]~]#CP Install. log/boot/#增量备份boot分区, and compress [[email protected]~]# dump-1uj-f/boot/boot.bak1.bz2/boot/# View the size of the file [email protected]~]# ll-h/root/-rw-r--r--.1Root root 18K -  -:xxboot.bak1.bz2-rw-r--r--.1Root root 20M -  .: Wuboot.bak.bz2# Query partition backup time and backup level [[email protected]~]# Dump-Wlast Dump (s) Done(Dump'>' filesystems):>/dev/sda5 (/) Last Dump:never/DEV/SDA1 (/boot) last Dump:level1, Date Sun -  .: -: to  ->/dev/sda2 (/Home) Last Dump:never>/dev/sdb1 (/root/Disk1) Last Dump:never>/dev/sdb5 (/root/disk5) Last Dump:never

Example 2: Backing up a file or directory

# Full backup/etc/~]# dump-0j-f/root/etc.dump.bz2/etc/

(2) Restore command

Restore command The format of restore is:

restore [mode options] [options]

Of these, there are four modes commonly used by the restore command, and these four modes cannot be mixed. Including:

-C-----Comparison mode, comparing the transformation of backup data and actual data

-I-----Enter interactive mode, manually select the files that need to be recovered

-T-----view mode for viewing what data is in the backup file

-R-----Restore Mode for data restore

The options include:-f------Specify the file name of the backup files

Example 1: Comparing the changes in backup data and actual data

#把boot目录中内核镜像文件改个名字 [[email protected]~]#MV/boot/vmlinuz-2.6. +-431. el6.i686/boot/vmlinuz-2.6. +-431. El6.i686.bak#restore found missing kernel image file [[email protected]~]# restore-c-f/root/boot.bak.bz2 Dump Tape is compressed. DumpDate: Sun -  .: Wu: the  -Dumped from:the epochlevel0Dump Of/boot on localhost.localdomain:/dev/Sda1label:nonefilesys= /bootrestore:unable toStat./vmlinuz-2.6. +-431. El6.i686:No suchfileor Directorysome files were modified!1Compare errors

Example 2: Viewing mode

[Email protected] ~]# restore-t-f/root/boot.bak.bz2 Dump Tape is compressed. DumpDate: Sun -  .: Wu: the  -Dumped from:the epochlevel0Dump Of/boot on localhost.localdomain:/dev/Sda1label:none2      .  One./lost+found32385./Grub32408./grub/grub.conf32386./grub/splash.xpm.gz32392./grub/Menu.lst32393./grub/Device.map32394./grub/Stage132395./grub/Stage232396./grub/e2fs_stage1_532397./grub/fat_stage1_532398./grub/ffs_stage1_532399./grub/iso9660_stage1_532400./grub/jfs_stage1_532401./grub/minix_stage1_532402./grub/reiserfs_stage1_532403./grub/ufs2_stage1_532404./grub/vstafs_stage1_532405./grub/xfs_stage1_532406./grub/. GRUB.CONF.SWP32387./EFI32388./efi/EFI32389./efi/efi/Redhat32390./efi/efi/redhat/Grub.efi A./.vmlinuz-2.6. +-431. El6.i686.hmac -./system.map-2.6. +-431. el6.i686 -./config-2.6. +-431. el6.i686 the./symvers-2.6. +-431. el6.i686.gz -./vmlinuz-2.6. +-431. el6.i686 -./initramfs-2.6. +-431. el6.i686.img

Example 3: Restore Mode

# (1mkdir~]# cd boot.test/-r-f/root/-r-f/root/  BOOT.BAK1.BZ2 Dump Tape is compressed.  + ) not found on tape# (2) Restore/-r-f etc.dump.bz2

Linux Learning notes (Linux)

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.