jcwillox / hassio-rclone-backup

Home Assistant addon to automatically sync backups to remote locations using Rclone
MIT License
120 stars 20 forks source link

Provide rclone.conf via yaml config #13

Closed ThomDietrich closed 2 years ago

ThomDietrich commented 2 years ago

Hey! For easy maintenance it is not ideal to have to configure this addon in two areas, through UI supported addon config and an additional rclone.conf. I am saying not ideal, because obviously all of us are capable to manage that, however, I wonder if there is a better way?

Did you ever explore ways to provide the content of rclone.conf via the yaml config?

Untested. This should pretty much do the trick:

schedule: 10 4 * * *
command: sync
sources:
  - /backup
destination: 'hassbackup:'
include:
  - DailyBackup*
# we can also disable google drive trash using flags
flags: 
  - --drive-use-trash=false
config: |
  [google]
  type = drive
  scope = drive
  token = REDACTED
  ; immediately delete backups instead of sending them to the trash
  use_trash = false
  [hassbackup]
  type = crypt
  remote = google:Backup/Home Assistant
  filename_encryption = off
  directory_name_encryption = false
  password = REDACTED
  password2 = REDACTED
jcwillox commented 2 years ago

I like this idea it would be much more convenient to have it in the UI, the only issue is that rclone wouldn't be able to write to the config, which currently isn't an issue, but could be if we add the rclone web UI. Still probably worth adding this 🤷

ThomDietrich commented 2 years ago

Good point and true. I would argue that a user that wants to use the rclone webUI doesn't need config: nor config_path:, a user that just wants to provide a fixed rclone.conf can go the config: or config_path route. Imho both config and config_path should exist and be mutually exclusive.

Are you going to work on this? I would be happy to provide a PR, but not before end of year ^^

jcwillox commented 2 years ago

Haha, only a 10 month turn around, dw I'll be adding this soon. I've just rewritten most of the core in golang, as it actually has a good scheduling library with support for cron-syntax. Won't be much extra effort to add support for this too 👍.

jcwillox commented 2 years ago

This is supported as of release 2.0.0 🎉, with the rclone_config option.

ThomDietrich commented 2 years ago

Great! Thank you

ThomDietrich commented 2 years ago

Hey! I've just setup a new system with this option and everything works perfectly.

Could you implement one improvement? Would be great if config_path was not mandatory, or if [] were supported. Currently I need to resort to this:

config_path: /config/rclone.conf_not-used
rclone_config: |
  [owncloud]
  type = webdav

Feels a bit counterintuitive and the added words are there to remind me of the fact that this option is not relevant.

jcwillox commented 2 years ago

Sure it can be changed to optional, however, you shouldn't have to rename config_path as it will be overridden when you specify rclone_config. Also, this should ideally be a separate feature request as it's easier to track.