我刚刚意识到 rdiff-backup 没有空运行:
rdiff-backup-bugs [sr #102557] --dry-run 开关
我不认为这是一个很大的需求,因为备份非常耗时且相当复杂,试运行将是一项艰巨的工作,恕我直言,价值不大。因此关闭。
是的,但是现在测试模式变得非常困难;如果您还没有目标目标,则无法使用compare
(致命错误:错误目录...它似乎不是 rdiff-backup 目标目录。),因此您基本上必须开始上传,然后等待只要需要看看你的模式是否有效。
所以,我将尝试用这个例子来演示:
mkdir /tmp/orig
touch /tmp/orig/a.txt
touch /tmp/orig/b.txt
touch /tmp/orig/c.txt
touch /tmp/orig/d.txt
mkdir /tmp/orig/sub1
mkdir /tmp/orig/sub2
touch /tmp/orig/sub1/e.bin
touch /tmp/orig/sub1/f.bin
mkdir /tmp/orig/sub2/__pycache__
touch /tmp/orig/sub2/__pycache__/test.pyc
touch /tmp/orig/sub2/__pycache__/test2.pyc
touch /tmp/orig/sub2/g.bin
我只想备份b.txt
、d.txt
、sub1/
和sub2/
- 但是,我不想要任何文件__pycache__
或*.pyc
文件。
我的第一次尝试:
$ rdiff-backup -v 5 --include '/tmp/orig/b.txt' --include '/tmp/orig/d.txt' --include='/tmp/orig/sub1/' --include='/tmp/orig/sub2/' --exclude="**__pycache__**" --exclude="**pyc" /tmp/orig /tmp/bckp_o
Using rdiff-backup version 2.0.0
with cpython /usr/bin/python3 version 3.8.10
on Linux-5.4.0-97-generic-x86_64-with-glibc2.29, fs encoding utf-8
Unable to import win32security module. Windows ACLs
not supported by filesystem at /tmp/orig
-----------------------------------------------------------------
Detected abilities for source (read only) file system:
Access control lists On
Extended attributes On
Windows access control lists Off
Case sensitivity On
Escape DOS devices Off
Escape trailing spaces Off
Mac OS X style resource forks Off
Mac OS X Finder information Off
-----------------------------------------------------------------
Unable to import win32security module. Windows ACLs
not supported by filesystem at /tmp/bckp_o/rdiff-backup-data/rdiff-backup.tmp.0
-----------------------------------------------------------------
Detected abilities for destination (read/write) file system:
Ownership changing Off
Hard linking On
fsync() directories On
Directory inc permissions On
High-bit permissions On
Symlink permissions Off
Extended filenames On
Windows reserved filenames Off
Access control lists On
Extended attributes On
Windows access control lists Off
Case sensitivity On
Escape DOS devices Off
Escape trailing spaces Off
Mac OS X style resource forks Off
Mac OS X Finder information Off
-----------------------------------------------------------------
Backup: escape_dos_devices = 0
Backup: escape_trailing_spaces = 0
Starting mirror /tmp/orig to /tmp/bckp_o
Processing changed file .
Processing changed file a.txt
Processing changed file b.txt
Processing changed file c.txt
Processing changed file d.txt
Processing changed file sub1
Processing changed file sub1/e.bin
Processing changed file sub1/f.bin
Processing changed file sub2
Processing changed file sub2/__pycache__
Processing changed file sub2/__pycache__/test.pyc
Processing changed file sub2/__pycache__/test2.pyc
Processing changed file sub2/g.bin
所以,不-不排除 pycache/.pyc ...
如果我首先移动 pyc 排除项,那么它似乎可以工作 - 但空的 pycache 目录仍会在目标上创建:
$ rdiff-backup -v 5 --exclude="**pyc" --include '/tmp/orig/b.txt' --include '/tmp/orig/d.txt' --include='/tmp/orig/sub1/' --include='/tmp/orig/sub2/' --exclude="**__pycache__**" /tmp/orig /tmp/bckp_o
...
Starting mirror /tmp/orig to /tmp/bckp_o
Processing changed file .
Processing changed file a.txt
Processing changed file b.txt
Processing changed file c.txt
Processing changed file d.txt
Processing changed file sub1
Processing changed file sub1/e.bin
Processing changed file sub1/f.bin
Processing changed file sub2
Processing changed file sub2/__pycache__
Processing changed file sub2/g.bin
所以,最后我也尝试移动pycache条件,
$ rdiff-backup -v 5 --exclude="**pyc" --exclude="**__pycache__**" --include '/tmp/orig/b.txt' --include '/tmp/orig/d.txt' --include='/tmp/orig/sub1/' --include='/tmp/orig/sub2/' /tmp/orig /tmp/bckp_o
...
Backup: escape_dos_devices = 0
Backup: escape_trailing_spaces = 0
Fatal Error: Last selection expression:
Command-line include glob: b'/tmp/orig/sub2/'
only specifies that files be included. Because the default is to
include all files, the expression is redundant. Exiting because this
probably isn't what you meant.
我不明白,默认是包含所有文件吗?-exclude
搬家之前怎么没有?什么是正确的语法,所以__pycache__
在这个例子中也被排除在外?