10

我想用重复备份以下文件夹

/home
/etc
/usr/local
/root
/var
/boot

并排除

/var/tmp
/var/run
/var/lock
/home/*/.thumbnails
/home/*/.cache
/home/*/.local/share/Trash
/root/.thumbnails
/root/.cache
/root/.local/share/Trash

我已经了解到我必须指定一个要保存的源目录,并且我可以使用includeexclude选项来调整它。

因此,我可以将/源目录作为源目录并排除**(这将一无所获)并包含我要保存的文件夹。

Source/--exclude /会给出一个空集,--include ...击败exclude并添加文件夹。但是,我将无法排除我想要排除的文件夹,对吧?还是我错过了什么?

4

2 回答 2

11

我发现包含/排除命令在命令中出现的越多,就越“强大”。

就我而言,导入和导出以及源代码如下所示:--exclude /var/tmp --exclude /var/run --exclude /var/lock --exclude /home/*/.thumbnails --exclude /home/*/.cache --exclude /home/*/.local/share/Trash --exclude /root/.thumbnails --exclude /root/.cache --exclude /root/.local/share/Trash --include /home --include /etc --include /usr/local --include /root --include /var --include /boot --exclude '**' /

(添加了换行符:)

--exclude /var/tmp 
--exclude /var/run
--exclude /var/lock
--exclude /home/*/.thumbnails
--exclude /home/*/.cache
--exclude /home/*/.local/share/Trash
--exclude /root/.thumbnails
--exclude /root/.cache
--exclude /root/.local/share/Trash
--include /home
--include /etc
--include /usr/local
--include /root
--include /var
--include /boot
--exclude '**'
/
于 2015-11-11T17:34:09.100 回答
4

要完成@Kurtibert 的答案,您需要**在包含的目录末尾添加以确保包含其中的文件(并且不要忘记引号):

--exclude '/var/tmp'
--exclude '/var/run'
--exclude /var/lock'
--exclude '/home/*/.thumbnails'
--exclude '/home/*/.cache'
--exclude '/home/*/.local/share/Trash'
--exclude '/root/.thumbnails'
--exclude '/root/.cache'
--exclude '/root/.local/share/Trash'
--include '/home/**'
--include '/etc/**'
--include '/usr/local/**'
--include '/root/**'
--include '/var/**'
--include '/boot/**'
--exclude '**'
/
于 2017-12-06T13:42:00.573 回答