Exclude rule not working for rclone rysnc for /.git/ repo

What is the problem you are having with rclone?

rclone sync

I am using rclone rysnc to sync a local folder to a folder path which is mounted to Filestore server.
We have a internal cloned version of rclone library. I am passing Exclude rule to exclude git files as below

indicatorsOpt := &filter.Opt{
MinAge: fs.DurationOff,
MaxAge: fs.DurationOff,
MinSize: fs.SizeSuffix(-1),
MaxSize: fs.SizeSuffix(-1),
ExcludeRule: string{ "/.git/”},
}
fileFilter, err := filter.NewFilter(indicatorsOpt)

open /<directory_path>/.git/objects/pack/pack-b7deb3571b66f08c42bae78b61e5ad1e1ad1c9cc.pack: permission denied

But this does not seem to work, it tries to sync files inside /.git/ repo. I have tried using filter rule, but it did not help.

Any suggestions on how we can avoid the rsync operation from syncing a particular folder?

Run the command 'rclone version' and share the full output of the command.

The repo was imported around 2018, so it is a very old version, only internal libraries are updated but not the rclone code base.

Which cloud storage system are you using? (eg Google Drive)

Local directory in a Kubernetes pod, rsync tries to sync local directory to another directory mounted to GCP Filestore.

The command you were trying to run (eg rclone copy /tmp remote:tmp)

  indicatorsOpt := &filter.Opt{
    MinAge:      fs.DurationOff,
    MaxAge:      fs.DurationOff,
    MinSize:     fs.SizeSuffix(-1),
    MaxSize:     fs.SizeSuffix(-1),
ExcludeRule: []string{ "**/.git/**”},
}
fileFilter, err := filter.NewFilter(indicatorsOpt)

I

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

Default config options are used and nothing specifically is set.

A log from the command that you were trying to run with the -vv flag

NA

welcome to the forum,

two different rules or is that just a type error when pasting into the forum?
which rule are you using?

i would test latest stable rclone, see what it does

fwiw, for testing filters, i prefer rclone ls src --dump=filters

My apologies, i am using ExcludeRule: []string{ "**/.git/**", "**/.nfs/**"}

Below is the output for dump filter

--- start filters ---
NOTICE: Config file "/.rclone.conf" not found - using defaults
--- File filter rules ---
 - (^|/).*/\.git/.*$
 - (^|/).*/\.nfs/.*$
--- Directory filter rules ---
 - (^|/).*/\.git/.*$
 - (^|/).*/\.nfs/.*$
--- end filters ---

as i suggested, the easist way to test a filter is on the command line and post the full debug output
rclone ls -vv --dump=filters --exclude=...

if .git is one-level deep from the root, then might want --exclude="/.git/"

Maybe it works. But rclone needs to list all objects in order to apply filters. And does not have permission to list things inside this .git directory.

It would help if you post full debug log for some small test data.

Thank you both for the suggestions.

I tried to install rclone in a pod and ran rclone ls -vv --dump=filters --exclude=... with ***/.git*** filter which did excluded git directory files. However when I tried the same call with our go library implementation, list did not exclude the git files. The dump filter outputs were same, so i guess our clone version(2018) is probably missing something.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.