docker-db-backup icon indicating copy to clipboard operation
docker-db-backup copied to clipboard

Cleanup does not work w/ PSQL + "all" databases

Open itsthejb opened this issue 1 year ago • 3 comments

Summary

Auto cleanup functionality doesn't work with Postgres when backing up all databases, since the find command search term doesn't include the all component of backup set filenames

Steps to reproduce

Example environment:

DEBUG_MODE: TRUE
USER_DBBACKUP: 0
GROUP_DBBACKUP: 0
CONTAINER_ENABLE_MONITORING: FALSE
DEFAULT_BACKUP_BEGIN: 0 3 * * 0
DEFAULT_CLEANUP_TIME: *CLEANUP_TIME
DEFAULT_LOG_LEVEL: DEBUG
# MariaDB
DB01_TYPE: mariadb
DB01_NAME: ALL
DB01_SPLIT_DB: FALSE
DB01_HOST: mariadb
DB01_USER: root
DB01_PASS: ...
# Postgres
DB02_TYPE: pgsql
DB02_NAME: ALL
DB02_SPLIT_DB: FALSE
DB02_HOST: postgresql
DB02_USER: root
DB02_PASS: ...

In this example, MariaDB backups are deleted correctly. Example filename is mariadb_all_mariadb_20241125-122007.sql.zst. Example find command from logs is find /backup/ -type f -mmin +20160 -iname 'mariadb_all_mariadb*' -exec rm -f '{}' ';'. Note the matching -iname argument.

However, this fails for PSQL. Example backup filename is pgsql_all_postgresql_20241020-030002.sql.zst including _all_ component as with MariaDB. However, the find command is:

find /backup/ -type f -mmin +20160 -iname 'pgsql__postgresql*' -exec rm -f '{}' ';'

Note that the required all component is missing in the -iname.

What is the expected correct behavior?

The cleanup find command should use the correct backup_job_filename_base, which is pgsql_all_postgresql in this case

Relevant logs and/or screenshots

  • Base is set correctly here for backup: https://github.com/tiredofit/docker-db-backup/blob/67f4326d0b70d59d7b8d226023448ca2af397ec9/install/assets/functions/10-db-backup#L823
  • However, checking later in the backup log I see backup_job_filename_base=pgsql__postgresql, which clearly overwrites the previous value and is the source of the bug

Environment

  • Image version / tag: tiredofit/db-backup:latest@sha256:58d319fc4ca790543a41a831bed9bf004d262e41f1cc3ee4d52d21688dc43fbb
  • Host OS: Alpine 3.20

Complete backup log

itsthejb avatar Nov 25 '24 13:11 itsthejb

This also appears to be an issue with Redis. Any progress on it?

robflate avatar Feb 15 '25 10:02 robflate

I'm still seeing this problem as well (postgres in my case). It does appear to be working on the mysql databases I have, however.

williamwgant avatar Jun 09 '25 13:06 williamwgant

I have the same problem with postgres databases

KardinalReusen avatar Nov 17 '25 20:11 KardinalReusen