feature: purge backup older than 14 days
Main / build (push) Successful in 7m35s Details

This commit is contained in:
RouxAntoine 2023-12-03 15:33:17 +01:00
parent 49837807e7
commit d795a16421
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
2 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,7 @@ RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8
RUN apt update && apt install pgtop
ENV LANG fr_FR.utf8
ENV PURGE_OLD false
ENTRYPOINT ["docker-entrypoint.sh"]

View File

@ -6,6 +6,13 @@ fileDt=$(date '+%d_%m_%Y_%H_%M_%S');
backUpFileName="postgres-backup-$fileDt.gz"
backUpFilePath="$BACKUP_DESTINATION_FOLDER/$backUpFileName"
if $PURGE_OLD; then DRY_RUN=false; else DRY_RUN=true; fi
echo "Following file are older than 14 day, it will be deleted (dry-run $DRY_RUN)"
find /var/lib/backup/ -type f -mtime +14 -name '*.gz' -execdir ls -- '{}' \;
if [ $PURGE_OLD = true ]; then
find /var/lib/backup/ -type f -mtime +14 -name '*.gz' -execdir rm -- '{}' \;
fi
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"