使用 tar -g 参数进行增量备份实验
完整备份:
#执行完整备份
tar -g snapshot -zcf back.tar.gz back
#查看 tarball 内容
[huzi@mail ~]$ tar ztf
back.tar.gz
back/
back/readme.txt
back/rmmysql_back.sh
back/mysqlbackup.sh
back/tuning-primer.sh
back/iptables.sh
back/backup.sh
back/MYSQL_BACKUP.sh
back/read.sh
back/backup.sh.bak
back/iptables
增量备份:
#新增一个档案
cp MySQLBackup.log back
#执行第一次的增量备份 (注意 tarball 档名)
tar -g snapshot -zcf back_incremental_1.tar.gz
back
#查看 tarball 内容
[huzi@mail ~]$ tar ztf
back_incremental_1.tar.gz
back/
back/MySQLBackup.log
#执行第二次的增量备份 (注意 tarball 档名)
tar -g snapshot -zcf
backup_incremental_2.tar.gz back
#查看 tarball 内容
[huzi@mail ~]$ tar ztf
back_incremental_2.tar.gz
back/
back/iptables
还原备份资料:
#清空测试资料
rm -rf test
#开始进行资料还原
tar zxf backup_full.tar.gz
tar zxf
backup_incremental_1.tar.gz
tar zxf backup_incremental_2.tar.gz
#查看测试资料
[huzi@mail ~]$ tar zxvf
back.tar.gz
back/
back/MYSQL_BACKUP.sh
back/backup.sh
back/backup.sh.bak
back/iptables.sh
back/mysqlbackup.sh
back/read.sh
back/readme.txt
back/rmmysql_back.sh
back/tuning-primer.sh
[huzi@mail
~]$ tar zxvf
back_incremental_1.tar.gz
back/
back/MySQLBackup.log
[huzi@mail ~]$
tar zxvf back_incremental_2.tar.gz
back/
back/iptables
[huzi@mail ~]$
ls back
backup.sh
iptables.sh MYSQL_BACKUP.sh
rmmysql_back.sh
backup.sh.bak MySQLBackup.log
readme.txt
tuning-primer.sh
iptables
mysqlbackup.sh read.sh
使用 tar -u 参数进行增量备份
第一次备份:
#备份资料
tar czvf back.tar.gz back
#查看 tarball 内容
[huzi@mail ~]$ tar ztf
back.tar.gz
back/
back/readme.txt
back/rmmysql_back.sh
back/mysqlbackup.sh
back/tuning-primer.sh
back/iptables.sh
back/backup.sh
back/MYSQL_BACKUP.sh
back/read.sh
back/backup.sh.bak
back/iptables
增量备份:
#新增一个档案, 并异动一个档案内容
cp MySQLBackup.log back
#执行增量备份 (-u 参数只能执行於未压缩的 tarball)
gunzip backup.tar.gz
tar uf
backup.tar back
gzip backup.tar
#查看 tarball 内容
tar ztf backup.tar.gz
[huzi@mail ~]$ tar ztf
back.tar.gz
back/
back/readme.txt
back/rmmysql_back.sh
back/mysqlbackup.sh
back/tuning-primer.sh
back/iptables.sh
back/backup.sh
back/MYSQL_BACKUP.sh
back/read.sh
back/backup.sh.bak
back/iptables
back/
back/MySQLBackup.log
[huzi@mail
~]$
还原备份资料:
#解包 tarball
tar zxf backup.tar.gz
原文地址:http://www.cnblogs.com/wayne173/p/3747355.html