Strange behavior with "exclude" option

Hi,

I’m new to restic. I successfully setted up my repository and backed up my first datas, with the exclude-file option, and everything is working as expected.

Backup details :

# excludes.txt
/opt/www/nextcloud/data/*.log
/opt/www/nextcloud/data/updater-*
/opt/www/nextcloud/data/appdata_*/preview
/opt/www/nextcloud/data/**/cache

restic backup --exclude-file excludes.txt -r ... /opt/www/nextcloud/data
start scan on [/opt/www/nextcloud/data]
start backup on [/opt/www/nextcloud/data]

And the following command gives me no result :

restic -r .... ls latest | grep .log  

But if I use the exclude option, with the exact same list of excluded path, some files are not excluded anymore :

restic backup --exclude /opt/www/nextcloud/data/*.log --exclude /opt/www/nextcloud/data/updater-* --exclude /opt/www/nextcloud/data/appdata_*/preview --exclude /opt/www/nextcloud/data/**/cache -r ... /opt/www/nextcloud/data
start scan on [/opt/www/nextcloud/data/updater.log /opt/www/nextcloud/data/admin/cache /opt/www/nextcloud/data/xxxxx/cache /opt/www/nextcloud/data/yyyyy/cache /opt/www/nextcloud/data]
start backup on [/opt/www/nextcloud/data/updater.log /opt/www/nextcloud/data/admin/cache /opt/www/nextcloud/data/xxxxx/cache /opt/www/nextcloud/data/yyyyy/cache  /opt/www/nextcloud/data]

restic -r .... ls latest | grep .log  
/opt/www/nextcloud/data/updater.log

It seems to work partially, because some files are still excluded, like nextcloud.log…

Am I missing something ?

Thanks a lot !

1 Like

If you specify wildcards on the command line without any quoting, then these are expanded by the shell before restic sees the parameters. This is also the reason why the list of file to backup includes /opt/www/nextcloud/data/updater.log.

restic backup --exclude /opt/www/nextcloud/data/*.log is expanded by the shell to something like

restic backup --exclude /opt/www/nextcloud/data/example.log /opt/www/nextcloud/data/updater.log

This command line requests that restic excludes /opt/www/nextcloud/data/example.log and backups /opt/www/nextcloud/data/updater.log. The correct syntax would be something like this:

restic backup --exclude "/opt/www/nextcloud/data/*.log"

Note the quotes around the file name.

3 Likes

Gosh, it was so simple… Thank you !