ttionya / vaultwarden-backup

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

Where to put the rclone configuration? #54

Closed Twilek-de closed 2 years ago

Twilek-de commented 2 years ago

Hi, I am trying to use vaultwarden-backup with docker-compose and I have mapped the config folder to a local folder like this ./rclone/:/config/ Then I put an rclone.conf file into the local rclone and into a rclone directory in the local rclone directory. But it won´t find it "rclone configuration information not found". Where is the right place and the right filename for the rclone config?? I did not find any info how to configure rclone in the docker-compose scenario.

ttionya commented 2 years ago

./rclone:/config/rclone/

Twilek-de commented 2 years ago

It still won´t find it. When I do the manual docker command to show the rclone config that you have in the readme it works and shows the config. Whith docker compose it doesn´t find it.

I am wondering as I am not using docker volumes. Is it a problem that the vaultwarden data is mapped for 2 containers simultanuosly?

ttionya commented 2 years ago

In fact I don't use docker volume either, I map the rclone folder to /config/rclone in the container. the local rclone folder has only the rclone.conf file.

This configuration has been used by me since before this project was created, and I can't understand why you have the problem of not being able to find the configuration file. Maybe you didn't restart via down and up?

docker-compose down && docker-compose up -d

Twilek-de commented 2 years ago

I did use docker-compose up and down each time.

This is my docker-compose.yml

` version: '3'

services: vaultwarden: image: vaultwarden/server:testing container_name: vaultwarden restart: always environment:

When I try to start this the backup container crashes with

backup_1 | ======================================== backup_1 | DATA_DIR: /bitwarden/data backup_1 | DATA_DB: /bitwarden/data/db.sqlite3 backup_1 | DATA_CONFIG: /bitwarden/data/config.json backup_1 | DATA_RSAKEY: /bitwarden/data/rsa_key backup_1 | DATA_ATTACHMENTS: /bitwarden/data/attachments backup_1 | DATA_SENDS: /bitwarden/data/sends backup_1 | ======================================== backup_1 | CRON: 5 backup_1 | RCLONE_REMOTE_NAME: minio:vaultwarden backup_1 | RCLONE_REMOTE_DIR: /BitwardenBackup/ backup_1 | RCLONE_REMOTE: minio:vaultwarden:/BitwardenBackup backup_1 | RCLONE_GLOBAL_FLAG: backup_1 | ZIP_ENABLE: TRUE backup_1 | ZIP_PASSWORD: 18 Chars backup_1 | ZIP_TYPE: zip backup_1 | BACKUP_FILE_DATE_FORMAT: %Y%m%d backup_1 | BACKUP_KEEP_DAYS: 0 backup_1 | MAIL_SMTP_ENABLE: FALSE backup_1 | TIMEZONE: UTC backup_1 | ======================================== backup_1 | rclone configuration information not found backup_1 | Please configure rclone first, check https://github.com/ttionya/vaultwarden-backup/blob/master/README.md#backup docker-vaultwarden_backup_1 exited with code 1

As the conainer immediately exits I cannot log into it to see how the directories are mapped or what the exact error is that rclone throws. I have tried using the rclone.conf with the manual docker command and it works. I have no clue why it fails.

ttionya commented 2 years ago

Everything looks normal.

You can modify the entrypoint and go into the container to confirm.

docker run --rm -it --entrypoint bash \
  -v $(pwd)/vw-data/:/bitwarden/data \
  -v $(pwd)/rclone/:/config/rclone \
  -e RCLONE_REMOTE_NAME="minio:vaultwarden" \
  ttionya/vaultwarden-backup:latest

After entering the container, you can check the /config/ directory or execute rclone config show "minio:vaultwarden".

Twilek-de commented 2 years ago

Hmmm this is strange, I think it has something to do with the way a s3 repository is invoked in rclone... The directories in the container get mapped ok. Doing ´rclone config show´ shows my config alright. Doing ´rclone config show "minio:vaultwarden"´ gets an ´Couldn't find type of fs for "minio:vaultwarden"´, which is probably the error with which the container with docker-compose exits. Giving an ´rclone copy /config/ minio:vaultwarden´ copies the files to the s3 repository without problems, so the rclone config should be valid. I have taken a look at your script and I think that you check the existence of a valid rclone config file with the show config call which fails in my setup. I think that this call will fail with all rclone file systems that not only have a name but also take an argument like the name of the bucket in my config.

ttionya commented 2 years ago

I understand, the remote name you configured is minio, vaultwarden is bucket name, so you set RCLONE_REMOTE_NAME to minio:[bucket], at this time rclone config show 'minio:vaultwarden' is not found, and rclone config show minio is correct.

If my understanding above is correct, try setting RCLONE_REMOTE_NAME to minio and RCLONE_REMOTE_DIR to vaultwarden/BitwardenBackup/ will it work?

Twilek-de commented 2 years ago

With this config there is only a warning ´NOTICE: S3 bucket vaultwarden path BitwardenBackup: Warning: running mkdir on a remote which can't have empty directories does nothing´ If I omit the BItwardenBackup the container starts without any errors. Both ways no files are copied, does the first backup start immediately upon the start of the container?

ttionya commented 2 years ago

If I omit the BItwardenBackup the container starts without any errors. Both ways no files are copied, does the first backup start immediately upon the start of the container?

No, backups are not performed at startup, only the configuration content is printed once, and the backup time is strictly according to the cron settings.

Twilek-de commented 2 years ago

Ah ok, I have waited a bit and a backup just showed up! Thanks a lot for the excellent support! This is very much appreciated!