mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-12-10 01:10:09 +03:00
How to run backup sql option introduced in 1.11.0 daily? #1975
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub.
Hi,
I noticed that in v1.11.0 there is a backup sql option in admin panel.
Is it possible to run this option daily or using cron inside container?
I don't want to use external container only for bitwarden database backup.
I like backup option in admin panel, but clicking it everyday is pain in the ass :)
Thanks
@mprasil commented on GitHub:
Apologies for not being clear. Yeah as @Haxy89 explained you probably want the files somewhere off the host. So I was just suggesting that if you have something in place to backup the files to some off-host location, maybe it can trigger the backup call before doing the actual file backup.
I think we could add some option to do backups on schedule, but it's non-trivial change as we'd have to implement cron-like functionality for that.
@BlackDex commented on GitHub:
@mprasil Within the container it could be possible to have a default cronjob or something which does this. And then according to a docker env it does this or not. Building in a cron like feature to bitwarden_rs it self is out of the scope i think.
Maybe an easy trigger/api call to execute the .backup command is nice, but that would be it in my opinion. Or maybe even an option to let it download that backup during that call. That is something which could be nice i think.
@BlackDex commented on GitHub:
It probably is easier to just run in a cron the .backup command on the database it self.
Or try to create a curl/wget command to run this command via the admin panel.
But then still as @mprasil stated. You want to have that backup somewhere off-site instead of the same location as the database is.
@ghost commented on GitHub:
"But I suppose you have to actually back up those files anyway, so maybe you can trigger the API to create backup the same way you trigger regular file backups?" What?
Currently I am using external container to do db backup.
Found out that with 1.11.0 there is an option to create db backup from admin panel.
Want do trigger this option automaticaly. No API trigger, no external container.
So this option is only for manual backup?
Can you add option to set timeout trigger for this option?
@mprasil commented on GitHub:
There is no cron inside so that isn't an option. But I suppose you have to actually back up those files anyway, so maybe you can trigger the API to create backup the same way you trigger regular file backups?
@mprasil commented on GitHub:
There is an option to do that we just need to wait until the version bubbles up in dependencies.
@ghost commented on GitHub:
So what is the purpose of this new "Backup Database" button?
Backup is created next to db file, user have to manualy click "Backup Database" and then manually move backup file somewhere else. It does not make sense
@BlackDex commented on GitHub:
That could be a nice option to write a wiki about.
A cron docker, which does the backups, and moves that backup file to some other volume maybe.
But i agree, adding cron features to bitwarden it self is a bad idea.
And isn't there a way to execute a command to sqlite via diesel now?
Which eliminates the needed external binary?
@mprasil commented on GitHub:
It is a backup, it's just not best practice to leave the backups on the same machine as live data, because if something happened to the machine itself, you'd lose both backup and live data. But
bitwarden_rscan only do so much for you.@BlackDex I think incorporating cron is a bit too much. We'd have to add some sort of init daemon and other moving parts inside the container. Considering the long term plan is to remove the
sqlite3binary and use built in functionality ofsqlitelibrary to do the backups, this would be step in the wrong direction.I think the docker way of doing things is set of small containers each doing its thing. There are images that do cron well. The practical overhead of running two separate containers is barely more than running a separate process.
@BlackDex commented on GitHub:
Well the purpose is to create a backup of the current database state.
You can use this for instance before you update the container, or just daily.
But it will create the backup right next to the live database file.
Also, i tested something just yet and come across a bug which i just fixed in a PR #660.
@mprasil commented on GitHub:
There's nice 3rd party image that people can use for backups. We link it from our wiki. I think this is the best option and it doesn't even use the API call. I suppose that's what @Haxy89 was using so far?
@mprasil commented on GitHub:
I'm going to close this as it's unlikely that we integrate cron inside the image or bitwarden_rs itself. I think the way you do it now is good easy and automated option.
@ghost commented on GitHub:
Yes, i was using this image but saw this „great” build in new option to do backups thinking it is doing the same