From 372f5c7a40e09d0c5de3ae0039b8196a5d2c9b26 Mon Sep 17 00:00:00 2001 From: Clemens Geibel Date: Fri, 16 Sep 2022 15:23:25 +0200 Subject: [PATCH] More fixed for backup image --- doc/BackupAndRestore.md | 8 ++++++-- .../image/resources/entrypoint-start-and-wait.sh | 2 ++ .../docker-backup/image/resources/entrypoint.sh | 4 +++- .../docker-backup/image/resources/init.sh | 2 +- .../image/resources/restic-snapshots.sh | 1 + .../docker-backup/image/resources/restore.sh | 16 ++++++++-------- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/doc/BackupAndRestore.md b/doc/BackupAndRestore.md index 68222bb..b15d4a1 100644 --- a/doc/BackupAndRestore.md +++ b/doc/BackupAndRestore.md @@ -31,7 +31,11 @@ 1. apply backup-and-restore pod: `kubectl scale deployment backup-restore --replicas=1` -2. exec into pod and execute restore pod (press tab to get your exact pod name) +2. Scale down gitea deployment: + `kubectl scale deployment gitea --replicas=0` +3. exec into pod and execute restore pod (press tab to get your exact pod name) `kubectl exec -it backup-restore-... -- /usr/local/bin/restore.sh` -1. remove backup-and-restore pod: +4. Start gitea again: + `kubectl scale deployment gitea --replicas=1` +5. remove backup-and-restore pod: `kubectl scale deployment backup-restore --replicas=0` diff --git a/infrastructure/docker-backup/image/resources/entrypoint-start-and-wait.sh b/infrastructure/docker-backup/image/resources/entrypoint-start-and-wait.sh index 0915071..c6addac 100644 --- a/infrastructure/docker-backup/image/resources/entrypoint-start-and-wait.sh +++ b/infrastructure/docker-backup/image/resources/entrypoint-start-and-wait.sh @@ -1,6 +1,7 @@ #!/bin/bash function main() { + create-pg-pass while true; do sleep 1m @@ -8,4 +9,5 @@ function main() { } source /usr/local/lib/functions.sh +source /usr/local/lib/pg-functions.sh main \ No newline at end of file diff --git a/infrastructure/docker-backup/image/resources/entrypoint.sh b/infrastructure/docker-backup/image/resources/entrypoint.sh index b25e15f..96df4f3 100755 --- a/infrastructure/docker-backup/image/resources/entrypoint.sh +++ b/infrastructure/docker-backup/image/resources/entrypoint.sh @@ -1,9 +1,11 @@ #!/bin/bash function main() { - + create-pg-pass + /usr/local/bin/backup.sh } source /usr/local/lib/functions.sh +source /usr/local/lib/pg-functions.sh main diff --git a/infrastructure/docker-backup/image/resources/init.sh b/infrastructure/docker-backup/image/resources/init.sh index 5767e69..baac041 100755 --- a/infrastructure/docker-backup/image/resources/init.sh +++ b/infrastructure/docker-backup/image/resources/init.sh @@ -4,7 +4,7 @@ function main() { file_env AWS_ACCESS_KEY_ID file_env AWS_SECRET_ACCESS_KEY - init-role-repo + #init-role-repo init-database-repo init-file-repo } diff --git a/infrastructure/docker-backup/image/resources/restic-snapshots.sh b/infrastructure/docker-backup/image/resources/restic-snapshots.sh index ca889ce..1d97a2c 100755 --- a/infrastructure/docker-backup/image/resources/restic-snapshots.sh +++ b/infrastructure/docker-backup/image/resources/restic-snapshots.sh @@ -7,6 +7,7 @@ function main() { file_env AWS_SECRET_ACCESS_KEY restic -r ${RESTIC_REPOSITORY}/files snapshots + restic -r ${RESTIC_REPOSITORY}/pg-database snapshots } source /usr/local/lib/functions.sh diff --git a/infrastructure/docker-backup/image/resources/restore.sh b/infrastructure/docker-backup/image/resources/restore.sh index b56b97d..0d9d10d 100755 --- a/infrastructure/docker-backup/image/resources/restore.sh +++ b/infrastructure/docker-backup/image/resources/restore.sh @@ -15,16 +15,16 @@ function main() { rm -rf /var/backups/restore restore-directory '/var/backups/restore' - rm -rf /data/gitea/* - rm -rf /data/git/repositories/* - cp /var/backups/restore/gitea/* /data/gitea/ - cp /var/backups/restore/git/repositories/* /data/git/repositories/ + rm -rf /var/backups/gitea/* + rm -rf /var/backups/git/repositories/* + cp -r /var/backups/restore/gitea/* /var/backups/gitea/ + cp -r /var/backups/restore/git/repositories/* /var/backups/git/repositories/ - # adjust file permissions - chown -R git:git /data + # adjust file permissions for the git user + chown -R 1000:1000 /var/backups - # Regenerate Git Hooks - /usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks + # TODO: Regenerate Git Hooks + #/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks # Restore db drop-create-db