36 lines
689 B
Bash
Executable file
36 lines
689 B
Bash
Executable file
#!/bin/bash
|
|
|
|
restoreDir=/etc/restore
|
|
giteaDir="$restoreDir/gitea"
|
|
|
|
hook_before() {
|
|
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"
|
|
}
|
|
|
|
hook_after() {
|
|
rm -rf "$giteaDir" || exit 1
|
|
}
|
|
|
|
hook_fail() {
|
|
:
|
|
}
|
|
|
|
hook_final() {
|
|
:
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
before) hook_before || exit $?;;
|
|
after) hook_after || exit $?;;
|
|
fail) hook_fail || exit $?;;
|
|
finally) hook_final || exit $?;;
|
|
esac
|