Rough gitea backup script
This commit is contained in:
parent
090289eafc
commit
543834a894
1 changed files with 37 additions and 0 deletions
37
backups/create_gitea_backup.sh
Normal file
37
backups/create_gitea_backup.sh
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Backup script for Gitea in a Kubernetes cluster
|
||||||
|
|
||||||
|
# `gitea dump` is a mess that we should not touch. We write our own backup scripts instead.
|
||||||
|
|
||||||
|
BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/gitea'
|
||||||
|
PASSFILE='./gitea_pass.txt'
|
||||||
|
|
||||||
|
# Retrieve container names
|
||||||
|
base_container="$( docker ps --format '{{.Names}}' | grep 'hugit-gitea_hugit-gitea' )"
|
||||||
|
database_container="$( docker ps --format '{{.Names}}' | grep 'hugit-postgresql_hugit-postgresql' )"
|
||||||
|
|
||||||
|
# Abort entire script if any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Enable maintenance mode
|
||||||
|
# Flush queues
|
||||||
|
docker exec "${base_container}" gitea manager flush-queues
|
||||||
|
# Pause queues
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# Backup the database
|
||||||
|
>&2 echo 'Backing up database'
|
||||||
|
database_backupfile="gitea-sqlbkp_$( date +'%Y%m%d' ).bak"
|
||||||
|
internal_database_backupfile="/tmp/${database_backupfile}"
|
||||||
|
docker exec --env-file "${PASSFILE}" "${database_container}" pg_dump 'gitea' -cwv -h 'localhost' -U 'gitea' -f "${internal_database_backupfile}"
|
||||||
|
docker cp "${database_container}":"${internal_database_backupfile}" "${BACKUP_DEST}"
|
||||||
|
|
||||||
|
# Backup files
|
||||||
|
zip -r "${BACKUP_DEST}/gitea-data_$( date +'%Y%m%d' ).zip" '/mnt/APPS/hugit'
|
||||||
|
|
||||||
|
# Disable maintenance mode
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# Double check
|
||||||
|
# gitea doctor --all --log-file /tmp/doctor.log
|
||||||
|
# TODO
|
Loading…
Reference in a new issue