我想用双面备份以下文件夹
/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
我已经了解到,我必须指定一个源目录来保存,并且我可以使用include
和exclude
选项进行调整。
因此,我可以将/
作为源目录,并排除**
(这将等于零),并包括我想要保存的文件夹。
源/
和--exclude /
将给出一个空集,--include ...
击败exclude
并添加文件夹。但是,我将无法排除我想排除的文件夹,对吧?还是我错过了什么?
我发现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 '**'
/
要完成@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 '**'
/