From 0852cb8c00d353477dcec8cd038da4452f6983a3 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 6 Oct 2022 17:07:05 +0200 Subject: [PATCH] feat: add postgres backup option --- Dockerfile | 2 +- scripts/mysql_backup.sh | 4 ++-- scripts/postgres_backup.sh | 10 ++++++++++ scripts/prefilebackup | 4 ++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 scripts/postgres_backup.sh diff --git a/Dockerfile b/Dockerfile index 0c3b8f5..ac5e6ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM debian -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wget lftp mariadb-client +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wget lftp mariadb-client postgresql-client ARG CLIENT_VERSION diff --git a/scripts/mysql_backup.sh b/scripts/mysql_backup.sh index 96bd4bf..2fc71ad 100644 --- a/scripts/mysql_backup.sh +++ b/scripts/mysql_backup.sh @@ -2,9 +2,9 @@ BACKUP_DIR="/backup/database" -echo "Starting to backup database" +echo "Starting to backup mysql database" mkdir --parents $BACKUP_DIR mysqldump --single-transaction --host=$MYSQL_BACKUP_HOST --user=$MYSQL_BACKUP_USER --password=$MYSQL_BACKUP_PASSWORD $MYSQL_BACKUP_DATABASE > $BACKUP_DIR/$MYSQL_BACKUP_DATABASE.sqldump -echo "Database backup finished" +echo "Mysql database backup finished" diff --git a/scripts/postgres_backup.sh b/scripts/postgres_backup.sh new file mode 100644 index 0000000..6fe2a4a --- /dev/null +++ b/scripts/postgres_backup.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +BACKUP_DIR="/backup/database" + +echo "Starting to backup postgres database" + +mkdir --parents $BACKUP_DIR +PGPASSWORD=$PG_PASSWORD pg_dump --host=$PG_HOST --username=$PG_USER $PG_DATABASE > $BACKUP_DIR/$PG_DATABASE.sqldump + +echo "Postgres database backup finished" diff --git a/scripts/prefilebackup b/scripts/prefilebackup index 72131ae..2f333a9 100644 --- a/scripts/prefilebackup +++ b/scripts/prefilebackup @@ -7,3 +7,7 @@ fi if [[ -n "$DO_MYSQL_BACKUP" ]]; then sh /usr/local/etc/urbackup/mysql_backup.sh fi + +if [[ -n "$DO_POSTGRES_BACKUP" ]]; then + sh /usr/local/etc/urbackup/postgres_backup.sh +fi