Linux tar命令常用方法
#备份文件
tar -zcvpf /backups/full-backup.tar.gz /home /etc
#备份不需要的文件exclude
tar -zcvpf /backups/full-backup.tar.gz -C / --exclude=mnt --exclude=media
#有txt需要备份文件列表
tar -zcvpf /backups/full-backup.tar.gz -T whatsbackup.txt
#给备份添加时间
tar -zcvpf /backups/full-backup_$(date +%Y%m%d-%H%M).tar.gz /home
#保存备份结果
tar -zcvpf /backups/full-backup_$(date +%F).tar.gz /home > /backups/logs/full-backup_$(date +%F).log
#增量备份
tar -N 2008-01-29 -zcvpf /backups/inc-backup_$(date +%F).tar.gz /home
#备份例子:
tar -cvpf /dev/st0 --label="Full-backup created on $(date +%Y%m%d-%H%M)." \
> -C / --exclude=var/spool/ etc home usr/local var/spool
tar -cvpf /dev/st0 --label="Incremental-backup created on $(date +%F)." \
> -N $(date -d yesterday "+%F") /etc /home
#恢复文件
tar -zxvpf /backups/full-backup_2008-01-29.tar.gz -C / \
> etc/passwd etc/shadow
tar -zcvpf /backups/full-backup.tar.gz /home /etc
#备份不需要的文件exclude
tar -zcvpf /backups/full-backup.tar.gz -C / --exclude=mnt --exclude=media
#有txt需要备份文件列表
tar -zcvpf /backups/full-backup.tar.gz -T whatsbackup.txt
#给备份添加时间
tar -zcvpf /backups/full-backup_$(date +%Y%m%d-%H%M).tar.gz /home
#保存备份结果
tar -zcvpf /backups/full-backup_$(date +%F).tar.gz /home > /backups/logs/full-backup_$(date +%F).log
#增量备份
tar -N 2008-01-29 -zcvpf /backups/inc-backup_$(date +%F).tar.gz /home
#备份例子:
tar -cvpf /dev/st0 --label="Full-backup created on $(date +%Y%m%d-%H%M)." \
> -C / --exclude=var/spool/ etc home usr/local var/spool
tar -cvpf /dev/st0 --label="Incremental-backup created on $(date +%F)." \
> -N $(date -d yesterday "+%F") /etc /home
#恢复文件
tar -zxvpf /backups/full-backup_2008-01-29.tar.gz -C / \
> etc/passwd etc/shadow
相关推荐
benico 2020-07-04
jackalwb 2020-06-21
wintelx 2020-06-11
大孩爱小孩 2020-05-07
zfyaixue 2020-02-24
神龙 2020-02-19
zmjzhangmj 2020-02-11
hickwu 2020-01-29
CurrentJ 2020-01-07
qonsnow 2013-03-27
xue0zhiqiang 2013-05-31
sunln00 2019-12-15
安得情怀似旧时 2019-12-10
xiaohouye 2019-12-02
FruitDrop 2013-08-22
fickyou 2013-08-20