resticprofiles-base/scripts/vaultwarden

37 lines
766 B
Text
Raw Normal View History

2023-12-03 02:09:46 -05:00
#!/bin/bash
restoreDir=/etc/restore
vaultwardenDir="$restoreDir/vaultwarden"
hook_before() {
2023-12-03 02:09:46 -05:00
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_after() {
2023-12-03 02:09:46 -05:00
rm -rf "$vaultwardenDir" || exit 1
}
hook_fail() {
:
}
hook_final() {
:
}
2023-12-03 02:09:46 -05:00
case "$1" in
before) hook_before || exit $?;;
after) hook_after || exit $?;;
fail) hook_fail || exit $?;;
finally) hook_final || exit $?;;
2023-12-03 02:09:46 -05:00
esac