From 726e3ab5c3736af0643b98248d7029c8c502ff59 Mon Sep 17 00:00:00 2001 From: marlon Date: Wed, 9 Apr 2025 15:13:16 -0400 Subject: [PATCH] new backup scripts --- backup-mattermost.sh | 16 ++++++++++++++++ backup-postgres.sh | 15 +++++++++++++++ compose.yml | 3 ++- restore.sh | 12 ------------ 4 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 backup-mattermost.sh create mode 100644 backup-postgres.sh delete mode 100644 restore.sh diff --git a/backup-mattermost.sh b/backup-mattermost.sh new file mode 100644 index 0000000..fa94e08 --- /dev/null +++ b/backup-mattermost.sh @@ -0,0 +1,16 @@ +if [ "$1" == "pre-backup" ]; then + exit +fi + +if [ "$1" == "pre-backup" ]; then + exit +fi + +if [ "$1" == "pre-restore" ]; then + # kill the running plugins that need to be overwritten + pkill plugins +fi + +if [ "$1" == "post-restore" ]; then + mmctl config reload --local +fi \ No newline at end of file diff --git a/backup-postgres.sh b/backup-postgres.sh new file mode 100644 index 0000000..71d0d94 --- /dev/null +++ b/backup-postgres.sh @@ -0,0 +1,15 @@ +if [ "$1" == "pre-backup" ]; then + exit +fi + +if [ "$1" == "post-backup" ]; then + exit +fi + +if [ "$1" == "pre-restore" ]; then + exit +fi + +if [ "$1" == "post-restore" ]; then + pg_restore -U $POSTGRES_USER -d $POSTGRES_DB -c /var/lib/postgresql/data/postgres-backup +fi \ No newline at end of file diff --git a/compose.yml b/compose.yml index 2048413..33a3f27 100644 --- a/compose.yml +++ b/compose.yml @@ -59,8 +59,9 @@ services: labels: backupbot.backup: "true" backupbot.backup.pre-hook: "PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} --format=directory -f /var/lib/postgresql/data/postgres-backup" - backupbot.backup.post-hook: "rm -rf /var/lib/postgresql/data/postgres-backup.sql" + backupbot.backup.post-hook: "rm -rf /var/lib/postgresql/data/postgres-backup" backupbot.backup.path: "/var/lib/postgresql/data/" + backupbot.restore.post-hook: "/backup-postgres.sh post" secrets: postgres_password: diff --git a/restore.sh b/restore.sh deleted file mode 100644 index 08f68bd..0000000 --- a/restore.sh +++ /dev/null @@ -1,12 +0,0 @@ -if [ "$1" == "pre" ]; then - mmctl - - -if [ "$1" == "post" ] - - - -reset_config() { - cp /config-to-copy.json /mattermost/config/config.json && touch /mattermost/config/CoopCloudManaged - mmctl config reload --local -} \ No newline at end of file