Issuess Excluding Directories


I have just discovered Rclone and have been working through creating some backups from my headless Ubuntu server to Google Drive. So far, I have managed simple backups but cannot get the syntax right to exclude directories.

In this case, I am trying to exclude the directory “Database” from the backup. I have been testing it using the code:
rclone sync /media/server/server/Management/Database g_storage:Database -v --exclude /media/server/server/Management/Database/Working/ --dry-run

When I run this, the output includes a number of messages like this:
2018/06/25 13:09:35 NOTICE: Working/Costing Sheet/Costing Sheet Estimate Code.txt: Not copying as --dry-run

As I understand it, this means that the files in the directory would be copied if it wasn’t a dry run.

I have tried:
rclone sync /media/server/server/Management/Database g_storage:Database -v --exclude /media/server/server/Management/Database/Working/** --dry-run

But I get the error message:
Command sync needs 2 arguments maximum

Eventually, I would like to run this as a scheduled script reading from an “eclude” list. The script runs the command:
rclone sync /media/server/server/Management/Database g_storage:Database -v --exclude-from /usr/local/sbin/scripts/exclude-list.txt --dry-run

The contents of the exclude list are:

This gives the same output suggesting that the directory and its contents would be copied if it wasn’t a dry run

Can anyone show me where I am going wrong?

What you need is this I think

rclone sync /media/server/server/Management/Database g_storage:Database -v --exclude "/Working/**" --dry-run

So the include / excludes are rooted from the root of the transfer. The leading / means root he directory at the root (ie don’t choose a Working directory anywhere in the path) and the trailing /** means exclude this directory and any of its contents.

Hope that helps!

Thank you so much, that works perfectly, it must be the one combination I didn’t try…

Going a bit off topic, how do you post code on this forum in the way that you have? I am used to the “code” tags on other forums but this forum doesn’t seem to have that feature.

Thanks again

You use markdown, either indent the line with 4 spaces or surround with three `




Here is what the forum developers have to say on the subject:

Thanks again :grinning:

1 Like