feature: add backup script
This commit is contained in:
parent
b920b8884e
commit
13788e43c1
@ -1,6 +1,7 @@
|
||||
FROM postgres:14.4-bullseye
|
||||
|
||||
COPY initScript/*.sh /docker-entrypoint-initdb.d/
|
||||
COPY backup-database.sh /backup-database.sh
|
||||
RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8
|
||||
ENV LANG fr_FR.utf8
|
||||
|
||||
|
20
backup-database.sh
Executable file
20
backup-database.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
dt=$(date '+%d/%m/%Y %H:%M:%S');
|
||||
fileDt=$(date '+%d_%m_%Y_%H_%M_%S');
|
||||
backUpFileName="postgres-backup-$fileDt.gz"
|
||||
backUpFilePath="$BACKUP_DESTINATION_FOLDER/$backUpFileName"
|
||||
|
||||
echo "$dt - Starting DB backup into file: $backUpFilePath";
|
||||
echo "$dt - Running: pg_dumpall -h $BACKUP_SOURCE_DB_HOST_NAME -U $POSTGRES_USER -c | gzip > $backUpFilePath"
|
||||
|
||||
pg_dumpall -h $BACKUP_SOURCE_DB_HOST_NAME -U $POSTGRES_USER -c | gzip > $backUpFilePath
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
rm $backUpFilePath
|
||||
echo "Unable to execute a BackUp. Please check DB connection settings"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$dt - DB backup completed into file: $backUpFilePath";
|
Loading…
Reference in New Issue
Block a user