Added vaultwarden backup agent
This commit is contained in:
parent
fbfffae58a
commit
6f4756b21e
1 changed files with 29 additions and 0 deletions
29
scripts/vaultwarden
Normal file
29
scripts/vaultwarden
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
restoreDir=/etc/restore
|
||||||
|
vaultwardenDir="$restoreDir/vaultwarden"
|
||||||
|
|
||||||
|
|
||||||
|
hook_check() {
|
||||||
|
if [[ -d "$vaultwardenDir" ]]; then
|
||||||
|
rm -rf "$vaultwardenDir" || exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
hook_pre() {
|
||||||
|
backupDate=$(date +"%Y-%m-%d")
|
||||||
|
vaultwardenHome=$(getent passwd vaultwarden | cut -f6 -d:)
|
||||||
|
|
||||||
|
mkdir -p "$vaultwardenDir"
|
||||||
|
sqlite3 "${vaultwardenHome}/data/db.sqlite3" ".backup '${vaultwardenDir}/db-${backupDate}.sqlite3'"
|
||||||
|
}
|
||||||
|
|
||||||
|
hook_post() {
|
||||||
|
rm -rf "$vaultwardenDir" || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
before_check) hook_check;;
|
||||||
|
before_backup) hook_pre;;
|
||||||
|
after_backup) hook_post;;
|
||||||
|
esac
|
Loading…
Reference in a new issue