Use dump restore to quickly back up and restore the FreeBSD system, dumpfreebsd
Note: This instance has passed the test in FreeBSD7.2 and is also applicable to FreeBSD8 or FreeBSD9. FreeBSD9 simplifies the number of default partitions and backup and recovery steps.
Environment: The company has several FreeBSD7.2 servers whose hard disks are aging and need to be replaced. As the company writes many applications that depend on php5.2 of earlier versions, if you upgrade FreeBSD, it will be troublesome (php5.2 is not available in the ports of FreeBSD for maintenance). Even if you reinstall FreeBSD7.2, it will be difficult to install ports because it is not officially maintained. In this way, you can use the dump and restore methods to directly back up and restore the hard disk.
Steps:
1. regularly dump each server in case of a hard disk failure to quickly recover the system
1. Shut down, mount the backup disk (used to store dump data), and unplug the hard disk line of the original FreeBSD system disk (to prevent data corruption due to misoperations)
2. USB flash drive pilot FreeBSD (I used FreeBSD8.2 USB flash drive) to partition and format the backup disk. In this step, you can use the sysinstall tool for convenience (only one partition can be used, it doesn't matter ).
3. Connect the original system disk, reboot the hard disk, and mount the backup disk (my disk is/bkdisk)
4. Write the backup script and run it in cron. My script dumpslice. sh:
#! /Bin/sh
# Program:
# Dump disk slice
# History:
#2014/09/10 yanglifeng First release
Bak_root = "/bkdisk/dumpfiles"
Dir_name = 'date + % Y % m % d'
# Create backup dir
Mkdir $ {bak_root}/$ {dir_name}
/Sbin/dump-0 Lauf $ {bak_root}/$ {dir_name}/ad4s1a_root.dump/dev/ad4s1a
/Sbin/dump-0 Lauf $ {bak_root}/$ {dir_name}/ad4s1d_var.dump/dev/ad4s1d
/Sbin/dump-0 Lauf $ {bak_root}/$ {dir_name}/ad4s1f_usr.dump/dev/ad4s1f
Df-h>/$ {bak_root}/sliceinfo.txt
For FreeBSD7 and FreeBSD8, only backup of/,/var,/usr,/tmp, And/dev is required.
My 1 TB hard drive dump every time for more than 1 hour
Cron is best executed when no one is using it, because the system response will be very slow during dump and will be almost unavailable.
Ii. restore in case of hard disk failure
1. Connect the new hard disk and unplug the original system disk and backup disk hard disk.
2. USB flash drive. Use sysinstall to format the new hard disk partition. The partitioning method is the same as that of the original system disk.
3. Connect the hard drive line of the backup disk and reboot the USB flash drive to enter the Fixit mode.
Mkdir/mnt/bkdisk # used to mount the backup disk
Mkdir/mnt/bkdisk/tmp
Export TMP_DIR =/mnt/bidisk/tmp # restore needs a relatively large/tmp directory
Mkdir/mnt/newdisk # used to mount the New Hard Disk slice
Mount/dev/adxs1x/mnt/bkdisk # mount backup disk
Mount/dev/ad4s1a/mnt/newdisk # mount the root partition of the New Hard Disk
Cd/mnt/newdisk
Restore-rf/mnt/bkdisk/ad4s1a_root.dump # restore root Partition
Cd/mnt
Umount/mnt/newdisk
Restore other partitions in the same way
4. Modify/etc/fstab and check whether the hard disk number corresponds to the new hard disk.
5. Restart the boot system with the new Hard Disk
Note:
1. If the original system disk is available, you can directly use dump and restore to copy the data on the original system disk to the new disk. For more information, see online, we recommend that you back up your data in any way. Otherwise, once data is lost, it cannot be restored.
2. dump can use network storage to store backup data
3. As long as it is a hardware supported by FreeBSD, the hard disk installed on the system can be mounted on any machine for normal use. You only need to modify the hard disk serial number in/etc/fstab and/etc/rc. nic name in conf
Appendix:
Copy partition to partition using dump and restore
The split area dump is provided to the target partition, and then the restore enters the original partition from the target partition to the new partition to copy the partition to the target partition, the process for copying is as follows:
※Step 1-2 can merge rows/stand/sysinstall, and then select Configure to use Fdisk and Label to split and format them.
For example, if you want to copy all the resources on/home (/dev/ad0s1h) to the partition (/dev/ad2s1h) on the new hard drive, click the following line:
# Newfs/dev/ad2s1h (if formatted, it can be omitted)
# Mount/dev/ad2s1h/mnt (omitted if mount is enabled)
# Cd/mnt
# Dump-0uaf-/home | restore-rf-
# Cd/
# Umount/mnt
Note that dump and restore do not have a specific shard name, but they all use a primary shard (-). For dump, it refers to the delivery of the partition data to a block and a block to the mark, while the restore is sent to and returned by the mark.
Reference:
FreeBSD system full backup: https://wiki.freebsdchina.org/doc/ B /backup_with_dump_and_restore
FreeBSD manual -- add hard drive: https://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/disks-adding.html
File System Management: http://www.twbsd.org/cht/book/ch06.htm
Yi Guoxiong -- System Backup: http://mail.lsps.tp.edu.tw /~ Gsyan/freebsd2001/backup.html
Q: What is the BACKUP command for centos 62 in linux? Dump and restore commands cannot be found?
Tar, cp, or dd
How to restore the sybase Database backed up by using dump? in LINUX
Load database A from '\ u \ databak \ a. dmp'
Online database
Note:
A: Database Name.
A \ databak \ u. dmp -- dump-down database, the path and file name stored on the server.
Before load, no user is required to connect to database.
After load, the original data is overwritten and cannot be restored.