Skip to content

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

Open
@itsthejb

Description

@itsthejb

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:
    backup_job_filename_base=pgsql_${db}_${backup_job_db_host,,}
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions