mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-06-12 05:07:40 +02:00
Add a CLI feature to backup the SQLite DB (#4906)
* Add a CLI feature to backup the SQLite DB Many users request to add the sqlite3 binary to the container image. This isn't really ideal as that might bring in other dependencies and will only bloat the image. There main reason is to create a backup of the database. While there already was a feature within the admin interface to do so (or by using the admin API call), this might not be easy. This PR adds several ways to generate a backup. 1. By calling the Vaultwarden binary with the `backup` command like: - `/vaultwarden backup` - `docker exec -it vaultwarden /vaultwarden backup` 2. By sending the USR1 signal to the running process like: - `kill -s USR1 $(pidof vaultwarden) - `killall -s USR1 vaultwarden) This should help users to more easily create backups of there SQLite database. Also added the Web-Vault version number when using `-v/--version` to the output. Signed-off-by: BlackDex <black.dex@gmail.com> * Spelling and small adjustments Signed-off-by: BlackDex <black.dex@gmail.com> --------- Signed-off-by: BlackDex <black.dex@gmail.com>
This commit is contained in:

committed by
GitHub

parent
544b7229e8
commit
e9acd8bd3c
22
src/util.rs
22
src/util.rs
@ -513,6 +513,28 @@ pub fn container_base_image() -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct WebVaultVersion {
|
||||
version: String,
|
||||
}
|
||||
|
||||
pub fn get_web_vault_version() -> String {
|
||||
let version_files = [
|
||||
format!("{}/vw-version.json", CONFIG.web_vault_folder()),
|
||||
format!("{}/version.json", CONFIG.web_vault_folder()),
|
||||
];
|
||||
|
||||
for version_file in version_files {
|
||||
if let Ok(version_str) = std::fs::read_to_string(&version_file) {
|
||||
if let Ok(version) = serde_json::from_str::<WebVaultVersion>(&version_str) {
|
||||
return String::from(version.version.trim_start_matches('v'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String::from("Version file missing")
|
||||
}
|
||||
|
||||
//
|
||||
// Deserialization methods
|
||||
//
|
||||
|
Reference in New Issue
Block a user