# Rclone rc backend/command not working as expected

**URL:** <https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834>\
**Category:** Suspected Bug\
**Created:** [August 31, 2020, 9:56am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834 "2020-08-31T09:56:00Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [August 31, 2020, 9:56am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/1 "2020-08-31T09:56:00Z")

</div>

#### What is the problem you are having with rclone?

Trying to switch over a teamdrive mounted by rclone with a service account. While the output shows it switches over, the config file gets updated, the mount is still using the original SA which it started with.  
At the moment SA1.json has errors on files, running the command seems to switch it over to SA2.json (it does in the output and in the config) but mount will only start using SA2.json on a remount.

#### What is your rclone version (output from `rclone version`)

v1.52.3 (tested with v1.50 to latest beta, all the same for me)

#### Which OS you are using and how many bits (eg Windows 7, 64 bit)

Debian 10

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

Google team drive

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

```auto
 rclone -q rc backend/command command=set fs=clouddrive: -o service_account_file=SA.json

```

#### The rclone config contents with secrets removed.

```auto
[clouddrive]
type = drive
scope = drive
service_account_file = SA1.json
team_drive = *
chunk_size = 64M

[cloudcrypt]
type = crypt
remote = clouddrive:Crypt2
filename_encryption = standard
password = *
password2 = *

```

#### A log from the command with the `-vv` flag

```auto
2020/08/31 17:53:14 DEBUG : rclone: Version "v1.52.3" starting with parameters ["rclone" "-vv" "rc" "backend/command" "command=set" "fs=clouddrive:" "-o" "service_account_file=/SA1.json"]
{
        "result": {
                "service_account_file": {
                        "current": "SA1.json",
                        "previous": "SA2.json"
                }
        }
}
2020/08/31 17:53:14 DEBUG : 4 go routines active

```

---

<div class="post-metadata">

**Author:** ![Animosity022](https://forum.rclone.org/user_avatar/forum.rclone.org/animosity022/32/451_2.png) [@Animosity022](https://forum.rclone.org/u/Animosity022)\
**Post date:** [August 31, 2020, 10:46am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/2 "2020-08-31T10:46:44Z")

</div>

Check out:

> <https://github.com/rclone/rclone/issues/4202>
>
> What is the problem you are having with rclone?
> https://forum.rclone.org/t/edit-service-account-while-mounted/15760
> a86196a
> After the thread above a new feature was introduced to set service account...

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [August 31, 2020, 10:48am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/3 "2020-08-31T10:48:38Z")

</div>

Thank, I did (multiple times) and re-read it multiple times today. As stated above I use the rc command as stated there. If there is something obvious that I'm missing in that post let me know 😉

---

<div class="post-metadata">

**Author:** ![Animosity022](https://forum.rclone.org/user_avatar/forum.rclone.org/animosity022/32/451_2.png) [@Animosity022](https://forum.rclone.org/u/Animosity022)\
**Post date:** [August 31, 2020, 10:49am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/4 "2020-08-31T10:49:26Z")

</div>

This line:

> <https://github.com/rclone/rclone/issues/4202#issuecomment-630930357>
>
> What is the problem you are having with rclone?
> https://forum.rclone.org/t/edit-service-account-while-mounted/15760
> a86196a
> After the thread above a new feature was introduced to set service account...

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [August 31, 2020, 11:09am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/5 "2020-08-31T11:09:20Z")

</div>

Thanks but that is for updating the config.

As stated there the rclone rc backend/command command=set fs=clouddrive: should be used to change the service account of a running mount. It SHOULD re-authenticate after running that command but for me it doesn't. I'm doing exactly as stated there and it looks like it works except for the auth part.

---

<div class="post-metadata">

**Author:** ![darthShadow](https://forum.rclone.org/user_avatar/forum.rclone.org/darthshadow/32/1322_2.png) [@darthShadow](https://forum.rclone.org/u/darthShadow)\
**Post date:** [August 31, 2020, 11:32am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/6 "2020-08-31T11:32:15Z")

</div>

What's your mount command?

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [August 31, 2020, 11:41am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/7 "2020-08-31T11:41:21Z")

</div>

See below, going to test it later with minimal mount command.

```auto
[Unit]
Description=
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
User=X
Group=X
ExecStart=/usr/bin/rclone mount \
        --config /home/X/.config/rclone/rclone.conf \
        --read-only \
        --allow-other \
        --allow-non-empty \
        --dir-cache-time=96h \
        --drive-chunk-size 32M \
        --buffer-size 256M \
        --vfs-read-chunk-size=128M \
        --vfs-read-chunk-size-limit off \
        --timeout 1h \
        --rc \
        --rc-no-auth \
        --log-level=DEBUG \
        --log-file=/home/X/logs/clouddrive.log \
        cloudcrypt: /home/X/.cloudcrypt
ExecStop=/bin/fusermount -uz /home/X/.cloudcrypt
Restart=on-abort

[Install]
WantedBy=default.target

```

I've complete a minimal test setup and the issue is still the same.  
Mounted a test using a new setup config with an SA that is known to have issues.

```auto
rclone mount testcrypt: /home/X/.test --rc --rc-no-auth --rc-addr=localhost:6000 --allow-other -vvv

```

ran rsync and monitored logs of the mount, Errors on the file in sync.

ran:

```auto
rclone rc --rc-addr=localhost:6000 backend/command command=set fs=test: -o service_account_file=/home/X/.config/rclone/SA/SA2.json

{
        "result": {
                "service_account_file": {
                        "current": "/home/X/.config/rclone/SA/SA2.json",
                        "previous": "/home/X/.config/rclone/SA/SA1.json"
                }
        }
}

```

Monitored logs of the mount and errors are still there, after stopping the mount and starting it back up again the rsync ran fine without any errors.

---

<div class="post-metadata">

**Author:** ![darthShadow](https://forum.rclone.org/user_avatar/forum.rclone.org/darthshadow/32/1322_2.png) [@darthShadow](https://forum.rclone.org/u/darthShadow)\
**Post date:** [August 31, 2020, 12:38pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/8 "2020-08-31T12:38:42Z")

</div>

The problem here seems to be that you are mounting the crypt remote and running the command on the drive remote. I don't think the backend command infra. traverses wrapped remotes. @ncw Thoughts?

* * *

Just to rule it out, can you try the following too:

- This is with the folder specified too

```auto
rclone rc --rc-addr=localhost:6000 backend/command command=set fs=clouddrive:Crypt2 -o service_account_file=/home/X/.config/rclone/SA/SA2.json

```

- This is with the crypt remote

```auto
rclone rc --rc-addr=localhost:6000 backend/command command=set fs=cloudcrypt: -o service_account_file=/home/X/.config/rclone/SA/SA2.json

```

I don't think either of them will work however, tbh.

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [August 31, 2020, 12:48pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/9 "2020-08-31T12:48:22Z")

</div>

```auto
rclone rc --rc-addr=localhost:6000 backend/command command=set fs=clouddrive:Crypt2 -o service_account_file=/home/X/.config/rclone/SA/SA2.json

```

command works, issue still there.

```auto
rclone rc --rc-addr=localhost:6000 backend/command command=set fs=cloudcrypt: -o service_account_file=/home/X/.config/rclone/SA/SA2.json

        "error": "command \"set\" failed: command not found",
        "input": {
                "command": "set",
                "fs": "testcrypt:",
                "opt": {
                        "service_account_file": "/home/X/.config/rclone/SA/SA2.json"
                }
        },
        "path": "backend/command",
        "status": 500
}

```

Doesn't work as RC doesn't run on crypt.

---

<div class="post-metadata">

**Author:** ![darthShadow](https://forum.rclone.org/user_avatar/forum.rclone.org/darthshadow/32/1322_2.png) [@darthShadow](https://forum.rclone.org/u/darthShadow)\
**Post date:** [August 31, 2020, 12:50pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/10 "2020-08-31T12:50:27Z")

</div>

Yep, that's what I expected. Will need to wait for ncw to chime in if there is something that can be done in the existing infra for this or something needs to be added to the infra.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [August 31, 2020, 1:54pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/11 "2020-08-31T13:54:34Z")

</div>

> [@darthShadow](#):
>
> The problem here seems to be that you are mounting the crypt remote and running the command on the drive remote. I don't think the backend command infra. traverses wrapped remotes.

If you want to run backend commands on the clouddrive remote then you will have to use `clouddrive:Crypt2` as the target. If you use `clouddrive:` then rclone will create a **new** remote and do the command on that, not do the command on the existing `clouddrive:Crypt2` remote.

So I would have expected @darthShadow s suggestion to work.

If it isn't working then it means that the right backend isn't being found.

@Iguana9999 Can you try

[v1.53.0-beta.4717.c31defbbd](https://beta.rclone.org/v1.53.0-beta.4717.c31defbbd/) on branch [master](https://github.com/rclone/rclone/tree/master) (uploaded in 15-30 mins)

with

```
rclone -q rc backend/command command=set fs=clouddrive:Crypt2 -o service_account_file=SA.json

```

I added a debug to show when backends are being created `Creating backend with remote %q` which should help debug what is going on.

Ideally we'd get the crypt backend to run translated commands on the backend it is wrapping, but I haven't figured out a sensible way of doing that yet.

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [August 31, 2020, 2:30pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/12 "2020-08-31T14:30:04Z")

</div>

I needed to change the mount names so test: is clouddrive and testcrypt is cloudcrypt.

rclone mount testcrypt: /home/X/.test --rc --rc-no-auth --rc-addr=localhost:6000 --allow-other -vvv

```auto
2020/08/31 22:19:17 DEBUG : rclone: Version "v1.53.0-beta.4717.c31defbbd" starting with parameters ["rclone" "mount" "testcrypt:" "/home/ernesto/.test" "--rc" "--rc-no-auth" "--rc-addr=localhost:6000" "--allow-other" "-vvv"]
2020/08/31 22:19:17 NOTICE: Serving remote control on http://127.0.0.1:6000/
2020/08/31 22:19:17 DEBUG : Creating backend with remote "testcrypt:"
2020/08/31 22:19:17 DEBUG : Using config file from "/home/X/.config/rclone/rclone.conf"
2020/08/31 22:19:18 DEBUG : Encrypted drive 'testcrypt:': Mounting on "/home/X/.test"

```

rclone rc backend/command command=set fs=test:Crypt2 -o service\_account\_file=SA.json

```auto
rc: "backend/command": with parameters map[command:set fs:test:Crypt2 opt:map[service_account_file:/home/X/.config/rclone/SA/SA1.json]]
2020/08/31 22:24:30 DEBUG : Creating backend with remote "test:Crypt2"
2020/08/31 22:24:31 DEBUG : Changing Service Account File from /home/X/.config/rclone/SA/SA1.json to /home/X/.config/rclone/SA/SA2.json
2020/08/31 22:24:31 DEBUG : Saving config "service_account_file" = "/home/X/.config/rclone/SA/SA2.json" in section "test" of the config file

```

rclone rc backend/command command=set fs=test: -o service\_account\_file=SA.json

```auto
2020/08/31 22:33:54 DEBUG : Creating backend with remote "test:"

```

Also tested with the none encrypted mount and that doesn't show a creating backend upon the rc command.

```auto
2020/08/31 22:45:27 DEBUG : Creating backend with remote "test:"
2020/08/31 22:45:27 DEBUG : Using config file from "/home/X/.config/rclone/rclone.conf"
2020/08/31 22:45:27 DEBUG : Google drive root '': Mounting on "/home/X/.test"
2020/08/31 22:45:27 DEBUG : : Root:
2020/08/31 22:45:27 DEBUG : : >Root: node=/, err=<nil>
2020/08/31 22:45:30 DEBUG : : Statfs:
2020/08/31 22:45:30 DEBUG : Google drive root '': read info from team drive "X"
2020/08/31 22:45:30 DEBUG : : >Statfs: stat={Blocks:274877906944 Bfree:274877906944 Bavail:274877906944 Files:1000000000 Ffree:1000000000 Bsize:4096 Namelen:255 Frsize:4096}, err=<nil>
2020/08/31 22:45:33 DEBUG : rc: "backend/command": with parameters map[command:set fs:test: opt:map[service_account_file:/home/X/.config/rclone/SA/SA1.json]]
2020/08/31 22:45:33 DEBUG : Changing Service Account File from /home/X/.config/rclone/SA/SA1.json to /home/X/.config/rclone/SA/SA2.json
2020/08/31 22:45:33 DEBUG : Saving config "service_account_file" = "/home/X/.config/rclone/SA/SA2.json" in section "test" of the config file
2020/08/31 22:45:33 DEBUG : Keeping previous permissions for config file: -rwxr-xr-x

```

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [August 31, 2020, 4:51pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/13 "2020-08-31T16:51:59Z")

</div>

OK, have a go with this - I think I worked out what the problem is - namely that crypt wasn't putting the drive backend into the cache so the rc command was never working.

I think I've fixed that and the backend lifecyle so hopefully this will work!

[v1.53.0-beta.4719.32dcc9cd4.fix-wrap-backends](https://beta.rclone.org/branch/fix-wrap-backends/v1.53.0-beta.4719.32dcc9cd4.fix-wrap-backends/) on branch [fix-wrap-backends](https://github.com/rclone/rclone/tree/fix-wrap-backends) (uploaded in 15-30 mins)

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [August 31, 2020, 11:54pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/14 "2020-08-31T23:54:22Z")

</div>

Testing gives me this, I assume I need to send it to test:Crypt2 as that one is not making an new backend so it uses the correct mount. For completion both to test: and test:Crypt2 added.

I don't have an SA with issues at the moment but I assume it works 😉

```auto
rclone rc --rc-addr=localhost:6000 backend/command command=set fs=test: -o service_account_file=/home/X/.config/rclone/SA/SA.json

2020/09/01 07:49:29 DEBUG : rc: "backend/command": with parameters map[command:set fs:test: opt:map[service_account_file:/home/X/.config/rclone/SA/SA]]
2020/09/01 07:49:29 DEBUG : Creating backend with remote "test:"

```

```auto
rclone rc --rc-addr=localhost:6000 backend/command command=set fs=test:Crypt2 -o service_account_file=/home/X/.config/rclone/SA/SA.json

2020/09/01 07:50:06 DEBUG : rc: "backend/command": with parameters map[command:set fs:test:Crypt2 opt:map[service_account_file:/home/ernesto/.config/rclone/SA/SA.json]]

```

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [September 1, 2020, 4:58pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/15 "2020-09-01T16:58:26Z")

</div>

> [@Iguana9999](#):
>
> Testing gives me this, I assume I need to send it to test:Crypt2 as that one is not making an new backend so it uses the correct mount.

Yes that looks correct 🙂

I'll merge this into master shortly so it will be in v1.53 when it is released (this week 🤞)

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [September 2, 2020, 1:03am UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/16 "2020-09-02T01:03:11Z")

</div>

Perfect! Should add a note to the example that when using an crypt the underlying FS:/path should be used instead of just the main FS.

Thanks for the always quick and on the point replies and fixes!

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [September 2, 2020, 5:15pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/17 "2020-09-02T17:15:20Z")

</div>

> [@Iguana9999](#):
>
> Perfect! Should add a note to the example that when using an crypt the underlying FS:/path should be used instead of just the main FS.

Where is that example?

You could send a PR if you wanted!

PS v1.53 is released with this fix

---

<div class="post-metadata">

**Author:** ![Iguana9999](https://forum.rclone.org/letter_avatar_proxy/v4/letter/i/b487fb/32.png) [@Iguana9999](https://forum.rclone.org/u/Iguana9999)\
**Post date:** [September 2, 2020, 11:53pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/18 "2020-09-02T23:53:22Z")

</div>

Thought I've seen it somewhere in the help of rclone while debugging but can't find it that fast.  
This is in the docs so seems to be clear anyway.

```auto
Note to run these commands on a running backend then see backend/command in the rc docs.

rclone backend <command> remote:path [opts] <args> [flags]

```

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [September 5, 2020, 11:53pm UTC](https://forum.rclone.org/t/rclone-rc-backend-command-not-working-as-expected/18834/19 "2020-09-05T23:53:25Z")

</div>

Closed on September 5, 2020, 11:53pm UTC

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