-
-
Notifications
You must be signed in to change notification settings - Fork 151
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:
docker exec container-name ls -la /usr/bin/backup*- Check the content of the backup-now script:
docker exec container-name cat /usr/bin/backup-nowWhat is the expected correct 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 executing backup-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-nowEnvironment
- Image version / tag:
tiredofit/db-backup:4.1.19 - Host OS: Docker on Linux (DietPi)
docker-compose.yml
services:
db-backup:
container_name: db-backup
image: tiredofit/db-backup
environment:
- 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: always
volumes:
- /mnt/backup/db:/backup
networks:
- postgres_network
- mariadb_default
networks:
postgres_network:
external: true
mariadb_default:
external: truePossible 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 now
EOF
else
echo "/usr/bin/backup${instance}-now now" > /usr/bin/backup-now # BUG: Should be >>
fiFix: Change line ~1270 from:
echo "/usr/bin/backup${instance}-now now" > /usr/bin/backup-nowTo:
echo "/usr/bin/backup${instance}-now now" >> /usr/bin/backup-nowThis 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:
docker exec container-name sh -c 'cat > /usr/bin/backup-now << EOF
#!/bin/bash
/usr/bin/backup01-now now
/usr/bin/backup02-now now
EOF'