I'm using rclone to make regular offsite backups of my whole Documents folder.
My Documents folder has a lot of git repos in it (I tend to use one-repo-per-project, and this includes all of my projects), and each one has lots of files in it (build artefacts, etc) and that means the backups take a long time.
I don't need my git repos synced, they're all pushed to various remotes as I go. So I want rclone to ignore all git repo folders. I'm currently using an excludes file (i.e. rclone sync--exclude-from ...), but keeping it up-to-date with all my git repos is tedious.
I know that I can exclude files/folders based on globs, but what I'd like to do is have rclone ignore any folder with a .git subfolder. Is this possible?
I know that I could programmatically create the excludes file with something like find ~/Documents -type d -name '.git', but I'm just wondering if there's a way to do that with rclone ignore patterns.
Run the command 'rclone version' and share the full output of the command.
I have a folder that is a git repo, do you want to exclude just the .git in the repo or whole repo directory?
felix@gemini:/opt/homescripts$ ls -al
drwxrwxr-x 1 felix felix 132 Aug 11 12:17 .
drwxrwxr-x 1 felix felix 124 Aug 25 16:07 ..
-rw-rw-r-- 1 felix felix 1961 May 7 06:54 Changes.MD
drwxrwxr-x 1 felix felix 204 Aug 11 12:18 .git
-rw-rw-r-- 1 felix felix 18 Apr 14 11:26 .gitignore
-rw-rw-r-- 1 felix felix 4261 Aug 11 12:17 PROXY.MD
-rw-rw-r-- 1 felix felix 1448 May 7 06:54 rclone.conf
-rw-rw-r-- 1 felix felix 11281 Aug 11 12:17 README.md
drwxrwxr-x 1 felix felix 264 May 9 12:29 scripts
drwxrwxr-x 1 felix felix 200 May 7 06:54 systemd
So the .git exclude would work great and remove that folder but not the rest of things.
If you want to remove the whole repo directory, you'd have to use something like exclude if present.
Yep @Ole thats the behaviour I’m after. And you’re also correct that the fact that .git is a folder not a file means that --exclude-if-present isn't a solution either.
Looks like I'll have to go with either the "quarantine all repos into a separate parent folder that doesn't get synced" solution, or the "generate the include file as part of the script" solution I mentioned above.