Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isssue with starting containers on Synology #107

Open
1kohm opened this issue Apr 6, 2023 · 10 comments
Open

Isssue with starting containers on Synology #107

1kohm opened this issue Apr 6, 2023 · 10 comments

Comments

@1kohm
Copy link

1kohm commented Apr 6, 2023

Hi,

thanks for the containers, it's something that I'm looking for to backup my local vaultwarden instance but I'm having problem with understanding how to acually setup that.
Here's what I've done so far:

  1. setup rclone with "docker run --rm -it --mount type=volume,source=vaultwarden-rclone-data,target=/config/ ttionya/vaultwarden-backup:latest rclone config"
  2. Result of rclone requested with "docker run --rm -it --mount type=volume,source=vaultwarden-rclone-data,target=/config/ ttionya/vaultwarden-backup:latest rclone config show" comamnd:

[BitwardenBackup]
type = smb
host = 10.0.0.130
user = rclone
pass = secretpasshashthatisprivate

  1. Instalation was done with docker.compose.yml file (see config below)
{
version: '3.4'

services:

  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: always
    environment:
      WEBSOCKET_ENABLED: "true"  # Enable WebSocket notifications.
      LOG_FILE: /data/vaultwarden.log
      INVITATIONS_ALLOWED: false
      SIGNUPS_ALLOWED: true
      EXTENDED_LOGGING: true
      LOG_LEVEL: trace
      PASSWORD_ITERATIONS: 700000
    #   ADMIN_TOKEN: 'your authentication token'
    ports:
     # - '127.0.0.1:8200:80'
     - 801:80	 
     - 3012:3012
    volumes:
      - ./vw-data:/data

  backup:
    image: ttionya/vaultwarden-backup:latest
    restart: always
    environment:
    #   RCLONE_REMOTE_NAME: 'BitwardenBackup'
    #   RCLONE_REMOTE_DIR: '/BitwardenBackup/'
    #   RCLONE_GLOBAL_FLAG: ''
    #   CRON: '5 * * * *'
    #   ZIP_ENABLE: 'TRUE'
    #   ZIP_PASSWORD: 'WHEREISMYPASSWORD?'
    #   ZIP_TYPE: 'zip'
    #   BACKUP_FILE_DATE_SUFFIX: ''
    #   BACKUP_KEEP_DAYS: 0
    #   PING_URL: ''
    #   MAIL_SMTP_ENABLE: 'FALSE'
    #   MAIL_SMTP_VARIABLES: ''
    #   MAIL_TO: ''
    #   MAIL_WHEN_SUCCESS: 'TRUE'
    #   MAIL_WHEN_FAILURE: 'TRUE'
    #   TIMEZONE: 'UTC'
    volumes:
      - ./vw-data:/bitwarden/data/
      - ./vaultwarden-rclone-data:/config/
    #   - /path/to/env:/.env

volumes:
  vaultwarden-data:
    # Specify the name of the volume where you save the vaultwarden data,
    # use vaultwarden-data for new users
    # and bitwardenrs-data for migrated users
    name: vaultwarden-data
    # name: bitwardenrs-data
  vaultwarden-rclone-data:
    external: true
    # Specify the name of the volume where you save the rclone configuration,
    # use vaultwarden-rclone-data for new users
    # and bitwardenrs-rclone-data for migrated users
    name: vaultwarden-rclone-data
    # name: bitwardenrs-rclone-data
}

Vaultwarden is running fine with that configuration but ttionya/vaultwarden-backup:latest container is failing to start and complaining that rclone is not configured correctly.

So what I am doing incorrectly?

date stream content
2023/04/06 21:25:22 stdout �[34mPlease configure rclone first, check https://github.com/ttionya/vaultwarden-backup/blob/master/README.md#backup�[0m
2023/04/06 21:25:22 stdout �[31mrclone configuration information not found�[0m
2023/04/06 21:25:22 stdout �[33m========================================�[0m
2023/04/06 21:25:22 stdout �[33mTIMEZONE: UTC�[0m
2023/04/06 21:25:22 stdout �[33mMAIL_SMTP_ENABLE: FALSE�[0m
2023/04/06 21:25:22 stdout �[33mBACKUP_KEEP_DAYS: 0�[0m
2023/04/06 21:25:22 stdout �[33mBACKUP_FILE_DATE_FORMAT: %Y%m%d�[0m
2023/04/06 21:25:22 stdout �[33mZIP_TYPE: zip�[0m
2023/04/06 21:25:22 stdout �[33mZIP_PASSWORD: 18 Chars�[0m
2023/04/06 21:25:22 stdout �[33mZIP_ENABLE: TRUE�[0m
2023/04/06 21:25:22 stdout �[33mRCLONE_GLOBAL_FLAG: �[0m
2023/04/06 21:25:22 stdout �[33mRCLONE_REMOTE: BitwardenBackup:/BitwardenBackup�[0m
2023/04/06 21:25:22 stdout �[33mCRON: 5 * * * *�[0m
2023/04/06 21:25:22 stdout �[33m========================================�[0m
2023/04/06 21:25:22 stdout �[33mDATA_DB: /bitwarden/data/db.sqlite3�[0m
2023/04/06 21:25:22 stdout �[33mDB_TYPE: SQLITE�[0m
2023/04/06 21:25:22 stdout �[33m========================================�[0m
2023/04/06 21:25:22 stdout �[33mDATA_SENDS: /bitwarden/data/sends�[0m
2023/04/06 21:25:22 stdout �[33mDATA_ATTACHMENTS: /bitwarden/data/attachments�[0m
2023/04/06 21:25:22 stdout �[33mDATA_RSAKEY: /bitwarden/data/rsa_key�[0m
2023/04/06 21:25:22 stdout �[33mDATA_CONFIG: /bitwarden/data/config.json�[0m
2023/04/06 21:25:22 stdout �[33mDATA_DIR: /bitwarden/data�[0m
@ttionya
Copy link
Owner

ttionya commented Apr 8, 2023

The command docker run --rm -it --mount type=volume,source=vaultwarden-rclone-data,target=/config/ ttionya/vaultwarden-backup:latest rclone config is used to generate an rclone configuration file, which is stored in the vaultwarden-rclone-data volume.

Please take a look at the docker-compose.yml file:

services:
  backup:
    volumes:
      - ./vaultwarden-rclone-data:/config/ # remove this line

Since you have already mapped the local directory ./vaultwarden-rclone into the container, you need remove this line and backup will work.

@ttionya ttionya added the troubleshooting There might be bug or it could be user error, more info needed label Apr 8, 2023
@1kohm
Copy link
Author

1kohm commented Apr 8, 2023

Hi @ttionya,
thanks for the tip. I've removed " - ./vaultwarden-rclone-data:/config/" from volumes (see the config below), recreated the containers but "ttionya/vaultwarden-backup:latest" still can't find the rclone configuration file that should be in "/config/" folder on container itself, as it is, right?

  backup:
    image: ttionya/vaultwarden-backup:latest
    restart: always
   # environment:
    #   RCLONE_REMOTE_NAME: 'BitwardenBackup'
    #   RCLONE_REMOTE_DIR: '/BitwardenBackup/'
    #   RCLONE_GLOBAL_FLAG: ''
    #   CRON: '5 * * * *'
    #   ZIP_ENABLE: 'TRUE'
    #   ZIP_PASSWORD: 'WHEREISMYPASSWORD?'
    #   ZIP_TYPE: 'zip'
    #   BACKUP_FILE_DATE_SUFFIX: ''
    #   BACKUP_KEEP_DAYS: 0
    #   PING_URL: ''
    #   MAIL_SMTP_ENABLE: 'FALSE'
    #   MAIL_SMTP_VARIABLES: ''
    #   MAIL_TO: ''
    #   MAIL_WHEN_SUCCESS: 'TRUE'
    #   MAIL_WHEN_FAILURE: 'TRUE'
    #   TIMEZONE: 'UTC'
    volumes:
      - ./vw-data:/bitwarden/data/
     # - ./vaultwarden-rclone-data:/config/
    #   - /path/to/env:/.env

volumes:
  vaultwarden-data:
    # Specify the name of the volume where you save the vaultwarden data,
    # use vaultwarden-data for new users
    # and bitwardenrs-data for migrated users
    name: vaultwarden-data
    # name: bitwardenrs-data
  vaultwarden-rclone-data:
    external: true
    # Specify the name of the volume where you save the rclone configuration,
    # use vaultwarden-rclone-data for new users
    # and bitwardenrs-rclone-data for migrated users
    name: vaultwarden-rclone-data
    # name: bitwardenrs-rclone-data

@1kohm
Copy link
Author

1kohm commented Apr 8, 2023

Hi,
I found my mistake :)
the problem was that I didn't understood the difference between two types of "volumes". There're named volumes and path volumes. My issue was that I've used path volume that's indicated with "./" instead of named one.
Here's the correct config that worked:

services:
  backup:
    volumes:
      - ./vw-data:/bitwarden/data/
      - vaultwarden-rclone-data:/config/

volumes:
  vaultwarden-rclone-data:
    external: true
    name: vaultwarden-rclone-data

Next question is how to configure the container environments variable to save backup files outside container in fileshare?

@ttionya
Copy link
Owner

ttionya commented Apr 8, 2023

This backup tool is based on rclone, and you can refer to the rclone documentation to confirm if it supports backing up to fileshare.

@1kohm
Copy link
Author

1kohm commented Apr 8, 2023

Hi,

now I can confirm that backup to smb with rclone wroks :)
I'm able to get it automatically backup via cron and files are being copied.

The last issue that I'm facing with is the restore.
Running that commands

  docker run --rm -it \
  --mount type=bind,source=/volume2/docker/vaultwarden-backup/vw-data/,target=/data/ \
  --mount type=bind,source=$(pwd),target=/bitwarden/restore/ \
  -e DATA_DIR="/data" \
  ttionya/vaultwarden-backup:latest restore --zip-file /volume2/docker/vaultwarden-backup/backup/backup.zip

Output that logs but when I login into vaultwarden then database is actually empty :(
How to troubleshoot that?

(Default: n): y
restore vaultwarden backup zip file

7-Zip (z) 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
 64-bit locale=C.UTF-8 Threads:4

Scanning the drive for archives:
1 file, 331483 bytes (324 KiB)

Extracting archive: /bitwarden/restore/backup.20230408.zip
--
Path = /bitwarden/restore/backup.20230408.zip
Type = zip
Physical Size = 331483


Enter password:secret

Everything is Ok

Files: 4
Size:       994816
Compressed: 331483
extract vaultwarden backup zip file successful
restore vaultwarden sqlite database
restore vaultwarden sqlite database successful
restore vaultwarden rsakey
restore vaultwarden rsakey successful
restore vaultwarden attachments
restore vaultwarden attachments successful
restore vaultwarden sends
restore vaultwarden sends successful

@ttionya
Copy link
Owner

ttionya commented Apr 9, 2023

If you are using docker-compose, you do not need to specify the DATA_DIR environment variable, remove it.

@1kohm
Copy link
Author

1kohm commented Apr 9, 2023

my sqlite database keeps failing after restarting container even without your container running.

[panic][ERROR] thread 'rocket-worker-thread' panicked at 'Error loading ciphers: DatabaseError(Unknown, "database disk image is malformed")': src/db/models/cipher.rs:633
So I'm trying different approach using mariadb, I got it running now, backup job with your container seems to create db.20230409.sql file but in your documentation point 3 in Restore section looks incomplete.
How I can test if restore is successful?

https://github.com/ttionya/vaultwarden-backup/blob/master/docs/using-the-mysql-or-mariadb-backend.md

@ttionya
Copy link
Owner

ttionya commented Apr 10, 2023

I cannot ascertain whether it is due to the backup tool or vaultwarden, but I came across an issue dani-garcia/vaultwarden#2851 related to Vaultwarden.

Perhaps, I should start considering ways to ensure the availability of backup files.

However, my familiarity with databases is limited, and with my recent workload being heavy, progress in this regard may be slow.

@1kohm
Copy link
Author

1kohm commented Apr 10, 2023

thanks for the input @ttionya, i really appreciate it. I belive that crashing sqlite database is due to corrupted WAL files and the fact that transactions are still being open while executing the backup.
That's the reason I'm planning to switch to more reliable mariadb, at least I hope :)

In regards to database restore I'm also a noob but I can at least confirm that executing that command will successfully restore mariadb database backup with your script. Only thing what would be great to add is that it could also restore whole vaultwarden /data directory. I think that shouldn't be diffiicult to write "restore" script that would do it all at once.

docker exec -i db_container_name mysql [--user yourusername] [--password=yourpassword] databasename < /path/to/db.dump

@ttionya ttionya added type: restore mistake User mistake type: config and removed troubleshooting There might be bug or it could be user error, more info needed labels Apr 11, 2023
@ttionya
Copy link
Owner

ttionya commented Apr 11, 2023

I apologize for not comprehending your meaning. The current restore script is restore the backup files to the /data directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants