forgejo-backup: Don't zip the archive to use it with borgmatic
This commit is contained in:
parent
ea9aad9459
commit
466c4509df
2 changed files with 9 additions and 11 deletions
|
@ -7,4 +7,4 @@ borgmatic_hooks:
|
|||
before_backup:
|
||||
- sudo -Hiu git /usr/local/bin/forgejo-backup.sh backup
|
||||
after_backup:
|
||||
- sudo -Hiu git /usr/local/bin/forgejo-backup.sh prune 1
|
||||
- sudo -Hiu git /usr/local/bin/forgejo-backup.sh prune 0
|
||||
|
|
|
@ -60,8 +60,6 @@ do_backup() {
|
|||
tar --delete -f "$output_dump_file" forgejo-db.sql
|
||||
tar --append -f "$output_dump_file" "$(basename $mysql_dump_file)"
|
||||
rm "$mysql_dump_file"
|
||||
chmod 640 "$output_dump_file" # Make the file readable by group for scp to different host by different user
|
||||
gzip "$output_dump_file"
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
|
@ -69,14 +67,14 @@ do_restore() {
|
|||
echo "Restoring Forgejo backup..."
|
||||
start_dir="$PWD"
|
||||
tar_file="$1"
|
||||
tar_dir="${tar_file%.tar.gz}" # Remove file extension
|
||||
chmod 600 "$tar_file" # Backup has changed permissions, restore them here
|
||||
echo "Extracting $tar_file..." && mkdir "$tar_dir" && tar xvzf "$tar_file" -C "$tar_dir" && echo " OK."
|
||||
tar_dir="${tar_file%.tar}" # Remove file extension
|
||||
stop_service
|
||||
echo -n "Extracting $tar_file..." && mkdir "$tar_dir" && tar xf "$tar_file" -C "$tar_dir" && echo " OK."
|
||||
cd "$tar_dir" || exit 1
|
||||
rm app.ini
|
||||
echo -n "Restoring $DATA_DIR..." && rsync -avz --delete data/ "$DATA_DIR" && rm -rf data && echo " OK."
|
||||
echo -n "Restoring $LOG_DIR..." && rsync -avz log/ "$LOG_DIR" && rm -rf log && echo " OK."
|
||||
echo -n "Restoring $REPO_DIR..." && mkdir -p "$REPO_DIR" && rsync -avz --delete repos/ "$REPO_DIR" && rm -rf repos && echo " OK."
|
||||
rm app.ini # Deployed with Ansible
|
||||
echo -n "Restoring $DATA_DIR..." && rsync -az --delete data/ "$DATA_DIR" && rm -rf data && echo " OK."
|
||||
echo -n "Restoring $LOG_DIR..." && rsync -az log/ "$LOG_DIR" && rm -rf log && echo " OK."
|
||||
echo -n "Restoring $REPO_DIR..." && mkdir -p "$REPO_DIR" && rsync -az --delete repos/ "$REPO_DIR" && rm -rf repos && echo " OK."
|
||||
echo -n "Changing ownership..." && chown -R git:git "$CONFIG_FILE" "$WORK_DIR" && echo " OK."
|
||||
echo -n "Restoring MySQL database..." && mysql --default-character-set=utf8mb4 -u"$MYSQL_USER" -p"$MYSQL_PW" "$MYSQL_DB" < forgejo-db.sql && rm forgejo-db.sql && echo " OK."
|
||||
cd "$start_dir" || exit 1
|
||||
|
@ -88,7 +86,7 @@ do_restore() {
|
|||
|
||||
do_prune() {
|
||||
echo "Pruning Forgejo backups and keeping $1 of them..."
|
||||
dumps=("$DUMP_DIR"/forgejo-dump-*.tar.gz)
|
||||
dumps=("$DUMP_DIR"/forgejo-dump-*.tar)
|
||||
nb_of_dumps="${#dumps[@]}"
|
||||
nb_to_keep="$1"
|
||||
nb_to_prune=$((nb_of_dumps - nb_to_keep))
|
||||
|
|
Loading…
Add table
Reference in a new issue