Vaultwarden Postgres backup

Hello, I am relatively new to Truenas and Docker.

I recently setup vaultwarden and I am looking for a valid way to backup my data, mainly the postgres database. I have mounted it as a bind mount points to a dedicated app dataset. Currently I am backing up the data folder to a Storj cloud sync container, but I as far as I know, it won’t be backing up the database properly. What would be the best practices for this?

Thanks!

use specialized tools

I understand that, but is there a way to automate it in the vaultwarden app container? or on the Truenas side? The vaultwarden docker that is included in the app section doesn’t contain the the tools unless you shell into the postgres container, which doesn’t have cron. This migtht be my lack of knowledge for docker.

You can export postgres’s port and connect to it from TrueNAS, provided it has pg_dump.

I ran Vaultwarden too, but today I use sqlite3 backend and I just backup via sqlite3 {{container_dir}}/db.sqlite3 ".backup /tmp/{{backup_dir}}/db.sqlite3" in ansbile that runs outside of docker

It came down to my lack of docker knowledge, but I figured it out.

The new version uses postgres, sqlite3 would have been a lot easier. I did some more research an figured out how to execute pg_dump in the postgres container from outside the container. Then I created a cron for this to run each day.

docker exec -it ix-vaultwarden-postgres-1 pg_dump -U vaultwarden -F t | gzip >/to/backup/folder/vault-$(date +%Y-%m-%d).tar.gz

Hope this helps someone else!

1 Like

yea that works too.

actually you reminded me that I need to upgrade sqlite to postgres