docker-volume-rclone icon indicating copy to clipboard operation
docker-volume-rclone copied to clipboard

Use command line args or env vars in addition to config file

Open sapk opened this issue 5 years ago • 4 comments

sapk avatar Sep 08 '18 09:09 sapk

You can completely remove any ~/.rclone.conf or ~/.config/rclone/rclone.conf, they are just consulted for defaults or fallback options. Try this:

rclone copy ./file.txt :sftp:subdir --sftp-host=localhost --sftp-key-file=~/.ssh/id_rsa

You can also add pass options via environment or mix it with CLI arguments:

export RCLONE_SFTP_HOST=localhost
export RCLONE_SFTP_KEY_FILE=~/.ssh/id_rsa
rclone ls :sftp:

Related action items, issues and documentation:

  • https://rclone.org/docs/#backend-path-to-dir
  • https://github.com/rclone/rclone/issues/633
  • https://github.com/rclone/rclone/issues/2697
  • https://github.com/rclone/rclone/issues/4685
  • https://github.com/restic/restic/issues/2411#issuecomment-719065803

ivandeex avatar Nov 08 '20 12:11 ivandeex

Also in a release after v1.54 rclone plans to natively support being called as a mount helper or from sytemd or automount. See https://github.com/rclone/rclone/issues/992#issuecomment-716185648 and below comments, and https://github.com/rclone/rclone/issues/2968

ivandeex avatar Nov 08 '20 12:11 ivandeex

Yes setting the file path is not mandatory but it is more explicit for other people reading the code.

I know that the arg/env configuration as greatly improve in rclone and de could do a lot better now but I think I will also keep the config file option since it will still be the easiest option to simple pass there rclone file.

For the mount option, I will have a look into it but it seems to be tricky to pass config to it.

sapk avatar Nov 08 '20 12:11 sapk

I will keep the config file option since it will still be the easiest option to simple pass there rclone file.

Rclone does and will support the environment way as well as command line for passing config file path:

export RCLONE_CONFIG=/path/to/rclone-via-env.conf
rclone --config=/path/to/rclone-override-env.conf mount ...

You can use the former version to pass base64-decoded config, but you'll have to implement the TODO as the <(base64 -d ...) trick won't work with environment.

For the mount option, I will have a look into it but it seems to be tricky to pass config to it.

In a future mount helper mode the config will be passed as

mount -t rclone -o rw,config=/path/to/rclone.conf ... remote: /mnt/path

However not every cli argument is generally possible to translate to environment as there is gotcha with boolean optons: compare --some-flag mount ..., --some-flag true mount ..., --some-flag=true mount ... etc.

ivandeex avatar Nov 08 '20 13:11 ivandeex