ttionya / vaultwarden-backup

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

Does it support postgresql database backup? #88

Closed Seele0oO closed 1 year ago

Seele0oO commented 1 year ago

Use this parameter.

DATABASE_URL: "postgresql://exampleuser:examplepasswd@db/postgres"

The vault can be stored to it. Using this approach you can create distributed vaultwarden.

So does this backup function support postgresql backup function?

Seele0oO commented 1 year ago
~/Documents/bitwarden/data ❯ tree                                                                                           12s 16:59:47
.
├── attachments
├── icon_cache
│   └── 1.cn.png.miss
├── rsa_key.pem
├── rsa_key.pub.pem
├── sends
└── tmp

At this point a password is stored in the database.

ttionya commented 1 year ago

@Seele0oO ,

I have researched and only need to modify a small amount of code to support PostgreSQL and MariaDB/MySQL .

But I'm not good with databases and don't know how to backup and restore PostgreSQL and MariaDB/MySQL data properly.

Another problem occurs in the restore phase, sqlite can be restored by just copying the db file to the folder, but other databases need to execute sql, this is also the aspect that bothers me.

If you can provide the shell command for PostgreSQL database backup and restore, I will finish the support for PostgreSQL as soon as possible. If you can also provide commands for MariaDB/MySQL, that would be great.

Seele0oO commented 1 year ago

Thank you for your attention,I have done some shell scripts, but I am not very skilled, so I wrote some example, hope it is useful for you.

https://github.com/Seele0oO/vaultwarden-backup/commit/b9e1c2496522fb264497b9822d810b1649a8a2c9

Seele0oO commented 1 year ago

by the way,It's not a good idea to use mysql, I think it's too heavy. There is some example. https://github.com/Seele0oO/vaultwarden-backup/commit/42272732db698716075e841ee96825d7b8f1f728

In my view,the MariaDB/MySQL is the same in commands. So it's probably universal.

ttionya commented 1 year ago

@Seele0oO ,

The PostgreSQL backend is now supported, try it on 1.16.0-beta.0.

Please let me know if you have any questions.

I will continue to add MySQL/MariaDB support.

Seele0oO commented 1 year ago

thanks for your work.I will test it in few days later.Take care yourself and be well. It is the time to sleeping.

ttionya commented 1 year ago

1.16.0-beta.1 is support Mysql(MariaDB) and PostgreSQL backend.

ttionya commented 1 year ago

1.16.0-beta.2 is support PostgreSQL 15. And earlier beta versions are no longer available.

Seele0oO commented 1 year ago

I'm wondering if I'm missing some environment variables that specify the backup method? In my tests, the data in the datagrip-connected postgresql database changed as I made changes, but the backup program still just backed up those files. image After I added some attachments to my test account, these two folders remained empty. image

ttionya commented 1 year ago

Please provide environment variables.

Seele0oO commented 1 year ago
vaultwarden:
  environment:
     SIGNUPS_ALLOWED: 'true'
     DATABASE_URL: 'postgresql://postgres:example@db/postgres'
backup:
    environment:
      CRON: '*/5 * * * *'
  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: example
ttionya commented 1 year ago

Sorry, please check the document.

ttionya commented 1 year ago

@Seele0oO ,

Hello, is the postgresql database backup working?

Seele0oO commented 1 year ago

It works fine on Debain 11. I can't test it with mysql because of the preformance of my password-server.

ttionya commented 1 year ago

Released stable version v1.16.0.