borgmatic-base/scripts/gitea

30 lines
571 B
Text
Raw Permalink Normal View History

2021-09-04 09:17:00 -04:00
#!/bin/bash
restoreDir=/etc/restore
giteaDir="$restoreDir/gitea"
hook_check() {
if [[ -d "$giteaDir" ]]; then
rm -rf "$giteaDir" || exit 1
fi
}
hook_pre() {
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_post() {
rm -rf "$giteaDir" || exit 1
}
case "$1" in
before_check) hook_check;;
before_backup) hook_pre;;
after_backup) hook_post;;
esac