Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork153
Description
Summary
When configuring multiple databases (DB01, DB02, etc.), the/usr/bin/backup-now script only contains the last database backup command instead of all configured databases. This causes manual backups to only execute the final database instead of all configured databases.
Steps to reproduce
- Configure multiple databases in docker-compose.yml:
environment: -DB01_TYPE=postgres -DB01_HOST=postgresql -DB01_NAME=ALL -DB01_USER=testuser -DB01_PASS=testpass -DB02_TYPE=mysql -DB02_HOST=mariadb -DB02_NAME=ALL -DB02_USER=root -DB02_PASS=testpass
- Start the container and verify individual scripts exist:
dockerexec container-name ls -la /usr/bin/backup*
- Check the content of the backup-now script:
dockerexec container-name cat /usr/bin/backup-nowWhat is the expectedcorrect behavior?
The/usr/bin/backup-now script should contain all configured database backup commands:
#!/bin/bash/usr/bin/backup01-now now/usr/bin/backup02-now nowWhen executingbackup-now, all configured databases should be backed up sequentially.
Relevant logs and/or screenshots
Actual output of backup-now (incorrect):
#!/bin/bash/usr/bin/backup02-now nowExpected output of backup-now (correct):
#!/bin/bash/usr/bin/backup01-now now/usr/bin/backup02-now nowDirectory listing shows all individual scripts exist:
-rwxr-xr-x 1 root root 26 Jul 3 00:10 backup-now-rwxr-xr-x 1 root root 221 Jul 3 00:10 backup01-now-rwxr-xr-x 1 root root 221 Jul 3 00:10 backup02-now
Environment
- Image version / tag:
tiredofit/db-backup:4.1.19 - Host OS: Docker on Linux (DietPi)
docker-compose.yml
services:db-backup:container_name:db-backupimage:tiredofit/db-backupenvironment: -CONTAINER_NAME=db-backup -CONTAINER_ENABLE_MONITORING=FALSE# Backup settings -DEFAULT_BACKUP_LOCATION=FILESYSTEM -BACKUP_JOB_CONCURRENCY=1 -DEFAULT_CHECKSUM=MD5 -DEFAULT_COMPRESSION=ZSTD -DEFAULT_BACKUP_INTERVAL=1440 -DEFAULT_BACKUP_BEGIN=0100 -DEFAULT_CLEANUP_TIME=8640# PostgreSQL backup -DB01_TYPE=postgres -DB01_HOST=postgresql -DB01_NAME=ALL -DB01_USER=${POSTGRES_USER} -DB01_PASS=${POSTGRES_PASSWORD} -DB01_AUTH=postgres# MariaDB backup -DB02_TYPE=mysql -DB02_HOST=mariadb -DB02_NAME=ALL -DB02_USER=root -DB02_PASS=${MYSQL_ROOT_PASSWORD}restart:alwaysvolumes: -/mnt/backup/db:/backupnetworks: -postgres_network -mariadb_defaultnetworks:postgres_network:external:truemariadb_default:external:true
Possible fixes
The issue is in/assets/functions/10-db-backup around line 1270. The script generation logic uses> (overwrite) instead of>> (append) for database instances other than "01":
Current code:
if ["${instance}"="01" ];then touch /usr/bin/backup-now chmod +x /usr/bin/backup-now cat<<EOF > /usr/bin/backup-now#!/bin/bash/usr/bin/backup${instance}-now nowEOFelseecho"/usr/bin/backup${instance}-now now"> /usr/bin/backup-now# BUG: Should be >>fi
Fix: Change line ~1270 from:
echo"/usr/bin/backup${instance}-now now"> /usr/bin/backup-now
To:
echo"/usr/bin/backup${instance}-now now">> /usr/bin/backup-now
This will append subsequent database commands to the backup-now script instead of overwriting the entire file.
Workaround: Users can manually fix the script after container startup:
dockerexec container-name sh -c'cat > /usr/bin/backup-now << EOF#!/bin/bash/usr/bin/backup01-now now/usr/bin/backup02-now nowEOF'