Yves Asked: 2018-03-22 23:39:39 +0800 CST2018-03-22 23:39:39 +0800 CST 2018-03-22 23:39:39 +0800 CST 如何备份和恢复系统级目录 772 我想备份目录如下: /usr /lib /etc /lib64 /boot /sbin /bin 有没有简单的做法? 我需要的是备份这些目录,我可以在需要时恢复它们。 我只知道,dd但似乎dd是备份整个磁盘。 backup restore 1 个回答 Voted Best Answer Null0007 2018-03-22T23:48:02+08:002018-03-22T23:48:02+08:00 DD 是有风险的命令,不推荐: https ://unix.stackexchange.com/a/141037/165083 您可以使用 rsync 代替它,但我使用类似这样的东西进行备份并将其上传到 AWS s3: function backup() { ###Path### pathToContent=${directory} pathToBackup=/home/backup/$(date +"%Y-%m-%d").${directory}.tar.gz ###Backup### echo "Creating tar.gz file for ${pathToContent}" tar -czf ${pathToBackup} ${pathToContent} echo "Uploading ${pathToBackup} to AWS s3" aws s3 cp --no-progress ${pathToBackup} s3://<BUCKET> echo "Removing ${pathToBackup}" rm ${pathToBackup} } cd <directory> for directory in $(ls -d */ | cut -f1 -d'/'); do echo "BACKUP FOR $directory starting now." backup $directory echo "Backup for ${directory} completed successfuly." done 请改变<directory>:)
DD 是有风险的命令,不推荐: https ://unix.stackexchange.com/a/141037/165083
您可以使用 rsync 代替它,但我使用类似这样的东西进行备份并将其上传到 AWS s3:
请改变
<directory>
:)