ttionya / vaultwarden-backup

Backup vaultwarden (formerly known as bitwarden_rs) SQLite3/PostgreSQL/MySQL/MariaDB database by rclone. (Docker)
MIT License
998 stars 115 forks source link

Ability to backup to mutliple rclone remotes #71

Closed badi95 closed 2 years ago

badi95 commented 2 years ago

First of all, thank you for your wonderful tool. I got it working backing up to my vps, but would like to also back up to a local directory that gets backed up to another remote site. Any plans to support multiple backup destinations?

ttionya commented 2 years ago

@badi95 ,

There are no plans that support simultaneous backups to multiple remote destinations.

You can specify multiple backup services in docker-compose.yml.

services:
  ...

  backup1:
    image: ttionya/vaultwarden-backup:latest
    restart: always
    environment:
      RCLONE_REMOTE_NAME: 'remote1'
      RCLONE_REMOTE_DIR: '/BitwardenBackup/'
      CRON: '5 * * * *'
    volumes:
      - vaultwarden-data:/bitwarden/data/
      - vaultwarden-rclone-data:/config/

  backup2:
    image: ttionya/vaultwarden-backup:latest
    restart: always
    environment:
      RCLONE_REMOTE_NAME: 'remote2'
      RCLONE_REMOTE_DIR: '/BitwardenBackup/'
      CRON: '10 * * * *'
    volumes:
      - vaultwarden-data:/bitwarden/data/
      - vaultwarden-rclone-data:/config/

There are several reasons why this is not supported now.

Firstly, to support multiple remote destinations without break changes, one needs to consider how to add environment variables. The current design makes it difficult to add.

Secondly, how to notify? What kind of email should be sent when partial success. Especially ping, I don't know if I should send ping when partial success, now it this means this backup is successful.

Considering that users using this tool will not have particularly large backup data, multiple backups will not have a significant performance impact, and the notification address can be specified at a more granular level, I think the method I provided above is sufficient.

Hope to receive your comments.

badi95 commented 2 years ago

I was thinking about the issue of how to handle the environment variable issue, and it could be done the same way the PATH variable handles it with a delimiter ":" if it were to be pursued. RCLONE_REMOTE_NAME: 'remote1:remote2' Then parse the list into a bash array, and verify the # of elements match.

I was considering forking and making something that might be viable if there is interest. If it's not something that's part of the vision of the tool, I'll probably just copy my backups manually or something. I was just thinking about that old adage about backups "two is one and one is none"

ttionya commented 2 years ago

@badi95 ,

The environment variable issue is easy to solve.

Using the separator to split RCLONE_REMOTE_NAME is problematic because : is a legal remoteName and is also legal in the path, so using it may cause processing errors.

I prefer that users can add RCLONE_REMOTE_NAME_1, RCLONE_REMOTE_NAME_2, etc. in order and use them with RCLONE_REMOTE_DIR_1, RCLONE_REMOTE_DIR_2 so that different remotes can use different directories.

The really difficult part is when to send notifications. Does a partial sync success count as success? Now that email can be set to send on success and send on failure, I don't want to add another environment variable that sends on partial success. Another one is sending pings to sites like healthcheck.io, which only sends on success, but should I send on partial success?

Translated with www.DeepL.com/Translator (free version)

badi95 commented 2 years ago

For the notification in my opinion if it fails any it would fail, which could be the default behavior. Much like the rest of the process, if it fails at any point it sends a failure.

There could be an environment variable for changing it to any passes it sends a pass to ping and email, if you think that people would want that.

On Wed, Jul 27, 2022 at 10:09 PM ttionya @.***> wrote:

@badi95 https://github.com/badi95 ,

The environment variable issue is easy to solve.

Using the separator to split RCLONE_REMOTE_NAME is problematic because : is a legal remoteName and is also legal in the path, so using it may cause processing errors.

I prefer that users can add RCLONE_REMOTE_NAME_1, RCLONE_REMOTE_NAME_2, etc. in order and use them with RCLONE_REMOTE_DIR_1, RCLONE_REMOTE_DIR_2 so that different remotes can use different directories.

The really difficult part is when to send notifications. Does a partial sync success count as success? Now that email can be set to send on success and send on failure, I don't want to add another environment variable that sends on partial success. Another one is sending pings to sites like healthcheck.io, which only sends on success, but should I send on partial success?

Translated with www.DeepL.com/Translator (free version)

— Reply to this email directly, view it on GitHub https://github.com/ttionya/vaultwarden-backup/issues/71#issuecomment-1197569128, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABR4AVFSWUFJJMNRYT5O7TVWHTUXANCNFSM54XIMRBA . You are receiving this because you were mentioned.Message ID: @.***>

ttionya commented 2 years ago

You are right, partial success should be considered a failure.

Having clarified the logic of environment variables and notifications, I think I can support multiple backup destinations.

I will start development in the next few days.

badi95 commented 2 years ago

Thank you! It looks great! Is there any way I can show my appreciation by donating?

ttionya commented 2 years ago

@badi95 ,

Thank you for the nice appraisal, very happy to help you!

I am not going to accept sponsorship at this time, thank you again.

badi95 commented 2 years ago

When setting this up I noticed you have to make sure to add the new remote to rclone before running with the new environment variables set, similar to the setup process for a single remote. Not sure if you want to note that in the README.