使用 tar 和 pingz 排除目录

使用 tar 和 pingz 排除目录

我不明白为什么我的排除不起作用:

tar --exclude=/{dev,proc,tmp,mnt,backup} -I pigz -cf backup.gz *

给我:

root@ca1:/# tar --exclude=/{dev,proc,tmp,mnt,backup} -I pigz -cf backup.gz *

tar: backup.gz: file changed as we read it
tar: proc/irq/11/smp_affinity: file changed as we read it
tar: proc/irq/26/smp_affinity: file changed as we read it
tar: proc/sys/net/ipv4/route/flush: Cannot open: Permission denied
tar: proc/sys/net/ipv6/route/flush: Cannot open: Permission denied
tar: proc/sys/vm/compact_memory: Cannot open: Permission denied
tar: proc/sys/vm/drop_caches: Cannot open: Permission denied

我猜我的语法不太正确(我已经尝试过将其作为单独的--exclude语句、引用、相对与绝对等)

答案1

典型 - 刚刚找到了方法:

tar -v --exclude='proc/*' \
    --exclude='dev/*' \
    --exclude='tmp/*' \
    --exclude='mnt/*' \
    --exclude='backup/*' \
    --exclude='sys/*' \
    --exclude='run/*' \
    --exclude='boot/*' \
    --exclude='backup.gz' \
-I pigz -cf backup.gz *

相关内容