为什么这个 rsnapshot 排除不起作用?

为什么这个 rsnapshot 排除不起作用?

Rsnapshot 将排除直接传递给 rsync,但 rsync 的行为似乎不一致。

我将我的 rsnapshot 备份测试简化为以下目录树(此树将被备份):

gorilla:~# find /tmp/snaptest -exec file {} \;
/tmp/snaptest: directory
/tmp/snaptest/SKIPTHIS: directory
/tmp/snaptest/SKIPTHIS/xyz: directory
/tmp/snaptest/SKIPTHIS/xyz/testing: ASCII text
/tmp/snaptest/SKIPTHIS/bar: ASCII text
/tmp/snaptest/SKIPTHIS/foo: ASCII text
/tmp/snaptest/SKIPTHIS.txt: ASCII text

我的配置文件:

config_version  1.2
snapshot_root   /tmp/backup-media
no_create_root  1
cmd_cp      /bin/cp
cmd_rm      /bin/rm
cmd_rsync   /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger  /usr/bin/logger
cmd_du      /usr/bin/du
interval    hourly  6
interval    daily   7
interval    weekly  4
interval    monthly 3
verbose     3
loglevel    3
logfile /media/maxtor-one-touch/rsnapshot.log
lockfile    /media/maxtor-one-touch/backups/.rsnapshot.pid
rsync_short_args    -a
rsync_long_args --delete --numeric-ids --relative --delete-excluded
exclude "SKIPTHIS/**"
link_dest   1
backup  /tmp/snaptest   snaptest

结果:

gorilla:~# rsnapshot -c /tmp/snaptest.conf hourly
echo 12638 > /media/maxtor-one-touch/backups/.rsnapshot.pid 
mkdir -m 0755 -p /tmp/backup-media/hourly.0/ 
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
    --exclude="SKIPTHIS/**" /tmp/snaptest \
    /tmp/backup-media/hourly.0/snaptest 
touch /tmp/backup-media/hourly.0/ 
rm -f /media/maxtor-one-touch/backups/.rsnapshot.pid 
gorilla:~# find /tmp/backup-media/ -exec file {} \;
/tmp/backup-media/: directory
/tmp/backup-media/hourly.0: directory
/tmp/backup-media/hourly.0/snaptest: directory
/tmp/backup-media/hourly.0/snaptest/tmp: sticky directory
/tmp/backup-media/hourly.0/snaptest/tmp/snaptest: directory
/tmp/backup-media/hourly.0/snaptest/tmp/snaptest/SKIPTHIS: directory
/tmp/backup-media/hourly.0/snaptest/tmp/snaptest/SKIPTHIS/xyz: directory
/tmp/backup-media/hourly.0/snaptest/tmp/snaptest/SKIPTHIS/xyz/testing: ASCII text
/tmp/backup-media/hourly.0/snaptest/tmp/snaptest/SKIPTHIS/bar: ASCII text
/tmp/backup-media/hourly.0/snaptest/tmp/snaptest/SKIPTHIS/foo: ASCII text
/tmp/backup-media/hourly.0/snaptest/tmp/snaptest/SKIPTHIS.txt: ASCII text

我的困惑源于这样一个事实:如果我复制粘贴 rsnapshot 回显的 rsync 命令,SKIPTHIS 目录将被排除!(我已经测试了其他各种 SKIPTHIS 模式,结果相同。)

知道发生什么事了吗?

答案1

开启 rsync 详细程度一路攀升显示问题:

rsync_short_args    -avvv

输出:

[client] add_rule(-s "SKIPTHIS/")

而当我复制粘贴到 shell 中时,shell 会消耗引号并且 rsync 说:

[client] add_rule(-s SKIPTHIS/)

将我的配置文件中的排除规则更改为:

exclude SKIPTHIS/**

作品。

相关内容