Skip to content

Support rclone connection strings with special characters. #1690

@itzTheMeow

Description

@itzTheMeow

Rclone has a Connection String feature that has partial support in rustic:

When using non-complicated strings like backblaze:

$ rustic -r "rclone::b2,account=XXXXXX,key=XXX/XX/XX+XXX:/xela-codes-nas" snapshots --log-level=debug
[INFO] using no config file, none of these exist: /home/xela/.config/rustic/rustic.toml, /etc/rustic/rustic.toml, ./rustic.toml
[DEBUG] (1) rustic_backend::rclone: starting rclone via CommandInput(_CommandInput { command: "rclone", args: ["serve", "restic", "--addr", "localhost:0", ":b2,account=XXXX,key=K005BhXXXX/XXX/X+XXXX:/xela-codes-nas"], on_failure: Error })
[DEBUG] (1) rustic_backend::rclone: using REST backend with url :b2,account=XXXX,key=XXX/XXX/X+XX:/xela-codes-nas.
enter repository password: [hidden]

it functions correctly

It also should be noted the double colon is required for the connection string to parse correctly, as it must begin with a colon when passed to rclone.

However, with more complicated backends such as pCloud which include quotes, it fails:

$ rustic -r "rclone::pcloud,token='{\"access_token\":\"XXXXX\",\"token_type\":\"bearer\",\"expiry\":\"0001-01-01T00:00:00Z\"}':/Misc/Backups/rustic" --log-level=debug snapshots
[INFO] using no config file, none of these exist: /home/xela/.config/rustic/rustic.toml, /etc/rustic/rustic.toml, ./rustic.toml
[DEBUG] (1) rustic_backend::rclone: starting rclone via CommandInput(_CommandInput { command: "rclone", args: ["serve", "restic", "--addr", "localhost:0", ":pcloud,token={\"access_token\":\"XXXXX\",\"token_type\":\"bearer\",\"expiry\":\"0001-01-01T00:00:00Z\"}:/Misc/Backups/rustic"], on_failure: Error })
[INFO] rclone output: 2026/02/28 02:59:15 CRITICAL: Failed to create file system for ":pcloud,token={\"access_token\":\"XXXX\",\"token_type\":\"bearer\",\"expiry\":\"0001-01-01T00:00:00Z\"}:/Misc/Backups/rustic": failed to configure Pcloud: unexpected end of JSON input

error: `rustic_core` experienced an error related to `running an external command`.

Message:
Could not load the backend `rclone Backend` at `:pcloud,token='{"access_token":"XXXX","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}':/Misc/Backups/rustic`. Please check the given backend and try again.
rclone exited before it could start the REST server: `exit status: 1`. Please check the exit status for more information.

rclone itself supports this feature:

$ rclone serve restic ":pcloud,token='{\"access_token\":\"XXX\",\"token_type\":\"bearer\",\"expiry\":\"0001-01-01T00:00:00Z\"}':"
2026/02/28 03:08:26 NOTICE: pcloud root '': Serving restic REST API on [http://127.0.0.1:8080/]
$ rclone about ":pcloud,token='{\"access_token\":\"XXXX\",\"token_type\":\"bearer\",\"expiry\":\"0001-01-01T00:00:00Z\"}':" 
Total:   X
Used:    X
Free:    X

I suspect this is due to the shell arguments being escaped when passed to rclone serve.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-triageStatus: Waiting for a maintainer to triage this issue/PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions