26 lines
598 B
Bash
Executable file
26 lines
598 B
Bash
Executable file
#!/bin/bash
|
|
|
|
restoreDir=/etc/restore
|
|
vaultwardenDir="$restoreDir/vaultwarden"
|
|
|
|
hook_pre() {
|
|
if [[ -d "$vaultwardenDir" ]]; then
|
|
rm -rf "$vaultwardenDir" || exit 1
|
|
fi
|
|
|
|
test -x "$(which sqlite3)" || exit 2
|
|
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_backup) hook_pre;;
|
|
after_backup) hook_post;;
|
|
esac
|