Filter in RestAPI mode

Hi Team,
I'm using rclone in my raspian to sync some folder to Google Drive. I'm using rclone in RC because I'm running the sync via RestAPI (curl or nodered flow).
I'm trying to invoke a sync via curl passing some filter definition without success.
I tried in different data body but it's not clear to me how to send the exclusion filter pattern via Rest API.

Can someone explain me better. I checked the documentation but honestly it's not totally clear to me how to use filter in API mode. Do you have an example?

Thanks
Ale.

Hi Ale,

You can find some good examples in the forum, but they are sometimes hard to find.

I guess this one will get you in the right direction:

I think you will find a filter example too if you follow all the links, otherwise feel free to ask again.

You need to put a _filter ={...} Into the request JSON blob in the body of the request.

Show me what you've tried and I'll tell you where you are going wrong.

Hi Ncw/Ole thank you both for your answer.
Yes I saw the link and I'm already able to raise a sync via Curl (I'm using postman).

Let me explain better what I would like to do. This is my folder structure (I created it for testing purpose):

/home/pi/backup/
├── folder1
│   ├── demo.txt
│   └── touch.txt
 ── folder2
│   └── touch.txt
└── folder3
    └── sensitive.txt

What I would to do is sync my backup folder to google drive but exclude all "demo.txt" files and also "sensitive.txt".

I can do it easly from command line with a syntax like this:

sync /home/pi/backup/ Google:tmp -vv --exclude demo.txt --exclude sensitive.txt

Unfortunately I could not do the same from Rest API (POSTing a JSON blob) it seems I'm not able
to specify an exclusion.

I try in different way:

{
    "srcFs": "/home/pi/backup",
    "dstFs": "Google:/tmp",
    "_filter" : {
        "_exclude":"demo.txt"
    },

    "_config": { "DryRun": true },
    "exclude" :  ["demo.txt"]

}

I also tried the following one but it should be anyway wrong:

{
    "srcFs": "/home/pi/backup",
    "dstFs": "Google:/backup/temp",
    "_filter" : {
        "_exclude":"demo.txt"
    },

    "_config": { "DryRun": true },
    "_filter": { 
        "exclude": "demo.txt"
    }
}

It seems to me (not yet tested) the only solution is to create a filter.txt in my main machine and raise it in __filter section. Am I correct?

How can I filter different file/folder in a sync command via a RestAPI call? The only way is to use a filter file? I would prefer to avoid it.

Thanks for clarifying to me this.

This is also a screenshot about my call:

Ale

Perhaps something like this (not tested):

{
    "srcFs": "/home/pi/backup",
    "dstFs": "Google:/tmp",
    "_filter": { "ExcludeRule": ["demo.txt","sensitive.txt"] },
    "_config": { "DryRun": true }
}

based on https://rclone.org/rc/#setting-filter-flags-with-filter

Hi Ole,
I already tried this anyway I tried again and unfortunately doesn't work.

The call completed successfully:

but the files are not excluded

If you need this is the command I use to run RClone in Daemon mode:

root@indastria:/home/pi/backup# rclone rcd --rc-addr 192.168.178.61:23080 --rc-no-auth 
2022/09/25 19:05:48 NOTICE: Serving remote control on http://192.168.178.61:23080/

And this is my version:

root@indastria:/home/pi/backup# rclone --version
rclone v1.53.3-DEV
- os/arch: linux/arm
- go version: go1.15.5

Ale

Hi Ale, it seems to be fine in my test:

I suggest you update to the latest version and try again. You can find it here: Rclone downloads

1 Like

Hi Ole,
you are totally right! With the new version is working!
Thanks! Ale

Hi Ale,
Glad to hear!
Happy coding, Ole

1 Like

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