怪我咯2017-04-17 16:16:55
rsync+btrfs+dm-crypt Backup the entire system - Evian's Blog.
In fact, it is recommended to use a file system that supports snapshots, such as zfs or btrfs (you can also use solutions such as LVM), otherwise there may still be consistency problems with online backup (for example, the PostgreSQL document clearly states that if you do not use snapshots way, it does not guarantee that your backup will be available).
PHPz2017-04-17 16:16:55
For industrial-grade backup, please write your own program to achieve at least the following functions:
1. Data replication, supports local replication and network replication.
2. Data verification.
Many people think that backup is just copying without verification, which leads to various problems in the end.
ringa_lee2017-04-17 16:16:55
Backup/Restore Linux with tar
备份系统(可以在运行时备份):
sudo su
cd /
tar pczf bak.tgz \
--exclude=/bak.tgz \
--exclude=/cdrom \
--exclude=/dev \
--exclude=/lost+found \
--exclude=/media \
--exclude=/mnt \
--exclude=/proc \
--exclude=/run \
--exclude=/sys \
--exclude=/tmp \
/
其中--exclude的作用是排除.
还原系统(建议在启动U盘(LiveCD)下还原):
sudo su
tar pxzf bak.tgz -C /
mkdir cdrom dev lost+found media mnt proc run sys tmp
参数p表明保留原文件的属性(属性不会依据使用者而变)
Backup/Restore MBR with dd
备份MBR:
dd if=/dev/sda of=/tmp/mbr bs=512 count=1
恢复MBR:
dd if=/tmp/mbr of=/dev/sda bs=512 count=1
怪我咯2017-04-17 16:16:55
rsync -aAXv /* /path/to/save/backup --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/path/to/backup/*}