ttionya / vaultwarden-backup

Backup vaultwarden (formerly known as bitwarden_rs) SQLite3/PostgreSQL/MySQL/MariaDB database by rclone. (Docker)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backup/Restore Problem

o0mba0o opened this issue · comments

Hi,
I want to copy my running vaultwarden docker instance to a new server.

The existing instance was started with:

docker run -d --name vaultwarden -v /vw-data/:/data/ -p 8899:80 vaultwarden/server:latest

The backups are created as follows:

docker run -d \  
    --restart=always  --name vaultwarden_backup \
    --volumes-from=vaultwarden \
    --mount type=volume,source=vaultwarden-rclone-data,target=/config/ \
    -e DATA_DIR="/data" \
    -e CRON="5 0 * * 0" \
    -e ZIP_TYPE="7z" \
    -e ZIP_PASSWORD="xxx" \
    -e BACKUP_KEEP_DAYS="30" \
    ttionya/vaultwarden-backup:latest

I used the same vaultwarden start command and stopped vaultwarden before the restore.
This is my restore command:

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

...this is the output:

Restore will overwrite the existing files, continue? (y/N)
(Default: n): y
restore vaultwarden backup zip file

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

Scanning the drive for archives:
1 file, 32432 bytes (32 KiB)

Extracting archive: /bitwarden/restore/backup.20221225.7z

Enter password:xxx

--
Path = /bitwarden/restore/backup.20221225.7z
Type = 7z
Physical Size = 32432
Headers Size = 304
Method = LZMA2:18 7zAES
Solid = +
Blocks = 1

Everything is Ok

Files: 4
Size:       241152
Compressed: 32432
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

After starting the vaulwarden container, I am not able to log into my account.

Username or password is incorrect. Try again

what am I doing wrong?

You run vaultwarden/server with the -v /vw-data/:/data/ parameter to mount the local /vw-data/ directory in the /data/ directory of the container.

But you restored the files to the /vw-data/ directory of the vaultwarden volume during the restore, you should change the --mount type=volume,source="vaultwarden",target=/vw-data/ in the restore command to --mount type=bind,source="/vw-data/", target=/data/, which is equivalent to -v /vw-data/:/data/.

I have two questions.

  1. Is your current directory /share/trash/ when restoring? I think so, otherwise the restore won't work.
  2. Even if the restore is to the vaultwarden volume, and you start the vaultwarden container still using the -v /vw-data/:/data/, that just doesn't apply the restored files, why would the account password be wrong?

thanks for the folder reference.

if i change:

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

to:

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

I get the following error message:

invalid argument "type=bind,source=/vw-data/," for "--mount" flag: invalid field '' must be a key=value pair
See 'docker run --help'.
  1. Yes
  2. I assumed that I could use a "clean" vaultwarden installation + restore of a backup. That means I do the restore and then try to log into my "old" account on the new server via the web interface. The error message (Username or password is incorrect. Try again ) came up.

invalid argument "type=bind,source=/vw-data/," for "--mount" flag: invalid field '' must be a key=value pair See 'docker run --help'

I didn't test it, maybe I added the space by mistake.

--mount type=bind,source="/vw-data/",target="/data/"

How stupid of me not to realize that. I thank you. restore worked