备份多个文件夹(包括/排除)

时间:2015-11-11 10:32:13

标签: backup duplicity duplicity-backup

我想用双面性备份以下文件夹

/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选项对其进行调整。

所以,我可以将/作为源目录并排除**(这将总结为什么)并包含我要保存的文件夹。

来源/--exclude /将提供空集,--include ...打败exclude并添加文件夹。但是,我将无法排除我想要排除的文件夹,对吧?或者我错过了什么?

2 个答案:

答案 0 :(得分:7)

我发现include / 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 '**' /

(添加换行符:)

--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 '**'
/

答案 1 :(得分:0)

要完成@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 '**'
/