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

Problem with mount:bind volume : Failed to create file system for "rclone_backup:/config" #29

Closed MilesTEG1 closed 3 years ago

MilesTEG1 commented 3 years ago

Hello, I'm trying to get your image working on my installation. I use Vaultwarden in docker on my Synology NAS (DS920+).

I don't use volume like you set in your docker-compose.yml file, but I use bind:mount volume with folders created on my NAS to store the data. But with this type of volume, there is an error and the container failed to start and no backup are done.

Is it possible to have your image working with a mount:bind volume ? And how ?

The container log :

========================================
DATA_DIR: /data
DATA_DB: /data/db.sqlite3
DATA_CONFIG: /data/config.json
DATA_RSAKEY: /data/rsa_key
DATA_ATTACHMENTS: /data/attachments
DATA_SENDS: /data/sends
========================================
CRON: * 0,30 * * *
RCLONE_REMOTE_NAME: rclone_backup
RCLONE_REMOTE_DIR: /config/
RCLONE_REMOTE: rclone_backup:/config
ZIP_ENABLE: TRUE
ZIP_PASSWORD: 18 Chars
ZIP_TYPE: 7z
BACKUP_FILE_DATE_FORMAT: %Y%m%d--%Hh%Mm%Ss
BACKUP_KEEP_DAYS: 7
MAIL_SMTP_ENABLE: FALSE
TIMEZONE: Europe/Paris
========================================
2021/05/12 08:21:08 NOTICE: Config file "/config/rclone/rclone.conf" not found - using defaults
2021/05/12 08:21:08 Failed to create file system for "rclone_backup:/config": didn't find section in config file

My docker-compose.yml file :

---
version: "2.4"

services:
  vaultwarden_backup_ttionya:     # Voir : https://github.com/ttionya/vaultwarden-backup
    image: ttionya/vaultwarden-backup:latest
    container_name: vaultwarden_backup_ttionya
    networks:
      - vaultwarden_network

    restart: always

    # depends_on:
    #   vaultwarden:
    #     condition: service_healthy

    labels:
      - "com.centurylinklabs.watchtower.enable=true"

    volumes:
      - /volume1/docker/vaultwarden/vaultwarden-data:/data
      # Chemin d'accès pour stocker le backup, voir https://github.com/ttionya/vaultwarden-backup
      - /volume1/docker/vaultwarden/vaultwarden-backup_ttionya:/config

    environment:
      - DATA_DIR=/data
      - RCLONE_REMOTE_NAME=rclone_backup
      - RCLONE_REMOTE_DIR=/config/

      # Utiliser soit SCHEDULE soit INTERVAL (ce dernier en sec)
      # Pour SCHEDULE : https://crontab.guru/#0_9_*_*_*
      # Ajouter un 0 en premier pour les secondes : secondes | minutes | heures | jour du mois | mois | jour de la semaine
      - CRON=* 0 * * *
      - ZIP_ENABLE=TRUE
      #- ZIP_PASSWORD=WHEREISMYPASSWORD?
      - ZIP_TYPE=7z
      - BACKUP_FILE_DATE_SUFFIX=--%Hh%Mm%Ss
      - BACKUP_KEEP_DAYS=7
      # - MAIL_SMTP_ENABLE=FALSE
      # - MAIL_SMTP_VARIABLES=''
      # - MAIL_TO=''
      # - MAIL_WHEN_SUCCESS='TRUE'
      # - MAIL_WHEN_FAILURE='TRUE'
      - TIMEZONE=Europe/Paris

networks:
  vaultwarden_network:
    external:
      name: vaultwarden_network

Thanks for your help.

ttionya commented 3 years ago

Hey @MilesTEG1 ,

The way the volume is mounted does not affect the backup tool working.

Based on the error message, it looks like the rclone/rclone.conf file does not exist in your /volume1/docker/vaultwarden/vaultwarden-backup_ttionya directory, do you have rclone configured?

You need to configure rclone in advance by running the following command:

docker run --rm -it \
  -v /volume1/docker/vaultwarden/vaultwarden-backup_ttionya:/config \
  ttionya/vaultwarden-backup:latest \
  rclone config

If you think you have configured it correctly, use rclone config show to check the configuration information

MilesTEG1 commented 3 years ago

Hello, No I didn't configure rclone, I thought it will be automaticaly configured with the environment variables...

i'll try to launch the command you gave me. But it forces me to use a SSH connection to launch the command. I usually use Portainer to create my containers with a docker-compose file. There is no other way than using a SSH command line ?

Thanks for your help.

MilesTEG1 commented 3 years ago

Ok, after configuring rclone and recreate the container with new parameters according to my rclone config, there is a backup done 😃 My docker-compose :

---
version: "2.4"

services:
  vaultwarden_backup_ttionya:     # Voir : https://github.com/ttionya/vaultwarden-backup
    image: ttionya/vaultwarden-backup:latest
    container_name: vaultwarden_backup_ttionya
    networks:
      - vaultwarden_network

    restart: always

    # depends_on:
    #   vaultwarden:
    #     condition: service_healthy

    labels:
      - "com.centurylinklabs.watchtower.enable=true"

    volumes:
      - /volume1/docker/vaultwarden/vaultwarden-data:/data
      # Chemin d'accès pour stocker le backup, voir https://github.com/ttionya/vaultwarden-backup
      - /volume1/docker/vaultwarden/vaultwarden-backup_ttionya:/config
      - /volume1/docker/vaultwarden/vaultwarden-backup_ttionya/rclone_backup:/rclone_backup

    environment:
      - DATA_DIR=/data
      - RCLONE_REMOTE_NAME=Backup_Syno
      - RCLONE_REMOTE_DIR=/rclone_backup/

      # Utiliser soit SCHEDULE soit INTERVAL (ce dernier en sec)
      # Pour SCHEDULE : https://crontab.guru/#0_9_*_*_*
      # Ajouter un 0 en premier pour les secondes : secondes | minutes | heures | jour du mois | mois | jour de la semaine
      - CRON=0,30 * * * *
      - ZIP_ENABLE=TRUE
      #- ZIP_PASSWORD=WHEREISMYPASSWORD?
      - ZIP_TYPE=7z
      - BACKUP_FILE_DATE_SUFFIX=--%Hh%Mm%Ss
      - BACKUP_KEEP_DAYS=7
      # - MAIL_SMTP_ENABLE=FALSE
      # - MAIL_SMTP_VARIABLES=''
      # - MAIL_TO=''
      # - MAIL_WHEN_SUCCESS='TRUE'
      # - MAIL_WHEN_FAILURE='TRUE'
      - TIMEZONE=Europe/Paris

networks:
  vaultwarden_network:
    external:
      name: vaultwarden_network

image

But the cron value seems to not be correctly interpreted... I want a back every 30 min... and I get a backup every minutes...

edit : my bad, my cron value wasn't correct... I edited to - CRON=0,30 * * * * dans now it works perfectly.

@ttionya Can you add in the documentation how to create the rclone.conf for a local backup ? It should be done by creating manually a file with (replace the RCLONE_REMOTE_NAME with the value you set in the docker-compose file :

[RCLONE_REMOTE_NAME]
type = local

Like this, there is no need to launch a command line in SSH.

ttionya commented 3 years ago

Hey @MilesTEG1 ,

I'm glad you solved the problem yourself.

Backing up files locally is not safe, especially since this backup file has your password in it. Considering that the person using this backup tool may not be familiar with backups, any advice prompting backups to local may mislead them. So I won't give them advice.

But I will add more prominent hints to the documentation for users to configure rclone, perhaps I will check if rclone.conf exists and give more explicit error instructions.

Finally I would suggest that you back up your files to cloud storage to prevent any local corruption.

MilesTEG1 commented 3 years ago

@ttionya Thanks to you, you gave me the indication about the rclone configuration.

For the fact that I'm backing-up to a local storage, what I didn't tell is that I backup every night severals local folders in drive1 to another drive in my NAS (for a fast recovery in case of the drive1 failed), AND, there is another backup to a cloud every night. So my /volume1/docker/ folder is backed-up every night on two different locations : another drive, and in a cloud.

For your image backup, I set up the cron to made the backup at 22h00, severals hours before the HyperBackup task (Synology inside).

I agree with you not advice to do a local backup. But for some, like me, the backup is more to recover from a database corruption, or container deffect, or for the drive failure.