#备份文件
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
Linux tar命令常用方法
转载请注明出处:服务器评测 » Linux tar命令常用方法