2023-12-03 02:09:46 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
restoreDir=/etc/restore
|
|
|
|
giteaDir="$restoreDir/gitea"
|
|
|
|
|
2023-12-03 06:44:35 -05:00
|
|
|
hook_before() {
|
2023-12-03 02:09:46 -05:00
|
|
|
if [[ -d "$giteaDir" ]]; then
|
|
|
|
rm -rf "$giteaDir" || exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
backupDate=$(date +"%Y-%m-%d")
|
|
|
|
giteaHome=$(getent passwd git | cut -f6 -d:)
|
|
|
|
|
|
|
|
mkdir -p "$giteaDir"
|
|
|
|
sudo -u git "${giteaHome}/bin/gitea" dump --type tar.xz --file - > "${giteaDir}/gitea-dump-${backupDate}.tar.xz"
|
|
|
|
}
|
|
|
|
|
2023-12-03 06:44:35 -05:00
|
|
|
hook_after() {
|
2023-12-03 02:09:46 -05:00
|
|
|
rm -rf "$giteaDir" || exit 1
|
|
|
|
}
|
|
|
|
|
2023-12-03 06:44:35 -05:00
|
|
|
hook_fail() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
hook_final() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-03 02:09:46 -05:00
|
|
|
case "$1" in
|
2023-12-03 06:44:35 -05:00
|
|
|
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
|