Skip to content

backup_and_restore silently suppresses errors e.g. when no storage is leftย #7038

@SailReal

Description

@SailReal

Contribution guidelines

Checklist prior issue creation

  • I understand that failure to follow below instructions may cause this issue to be closed.
  • I understand that vague, incomplete or inaccurate information may cause this issue to be closed.
  • I understand that this form is intended solely for reporting software bugs and not for support-related inquiries.
  • I understand that all responses are voluntary and community-driven, and do not constitute commercial support.
  • I confirm that I have reviewed previous issues to ensure this matter has not already been addressed.
  • I confirm that my environment meets all prerequisite requirements as specified in the official documentation.

Description

In the current implementation of helper-scripts/backup_and_restore.sh, many backup errors are suppressed. This is problematic because the script can exit successfully while producing an incomplete backup; since verifying parity with live data isnโ€™t straightforward, the script should fail fast on backup errors (e.g., out-of-disk space).

Adding set -Eeuo pipefail at the top of the script would prevent a lot of silent failures. If you agree, I can create a PR.

A workaround is to call it e.g. via bash -Eeo pipefail "$backup_script" backup all --delete-days 1

Steps to reproduce:

  1. Create a backup on a device where the storage is almost full
  2. Backup fails but exit code is success (0)

Logs:

/opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh backup all --delete-days 1
Using 1 Thread(s) for this run.
Notice: You can set the Thread count with the THREADS Variable before you run this script.
Using /mnt/temp-data as backup/restore location.

Found project name mailcowdockerized
Checking Docker image: ghcr.io/mailcow/backup:latest
Image update available, pulling ghcr.io/mailcow/backup:latest
latest: Pulling from mailcow/backup
Digest: sha256:c6de22520a423bf0ffc5de5927369ce07de8e0e8811ec2058028129e5816d1df
Status: Image is up to date for ghcr.io/mailcow/backup:latest
ghcr.io/mailcow/backup:latest
Successfully pulled ghcr.io/mailcow/backup:latest

/vmail/
...
zstd: error 70 : Write error : cannot write block : No space left on device
/bin/tar: /backup/backup_vmail.tar.zst: Wrote only 4096 of 10240 bytes
/bin/tar: Child returned status 70
/bin/tar: Error is not recoverable: exiting now
/crypt/
/crypt/ecpubkey.pem
/crypt/ecprivkey.pem
/crypt/keys/
zstd: /*stdout*\: No space left on device
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
OK
/redis/
/redis/dump.rdb
zstd: error 70 : Write error : cannot write block : No space left on device
/bin/tar: /backup/backup_redis.tar.zst: Wrote only 4096 of 10240 bytes
/bin/tar: Child returned status 70
/bin/tar: Error is not recoverable: exiting now
/rspamd/
...
zstd: error 70 : Write error : cannot write block : No space left on device
/bin/tar: /backup/backup_rspamd.tar.zst: Cannot write: Broken pipe
/bin/tar: Child returned status 70
/bin/tar: Error is not recoverable: exiting now
/postfix/
...
zstd: /*stdout*\: No space left on device
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
Using SQL image mariadb:10.11, starting...
Obsolete option: rsync. Ignored
[00] 2026-01-30 10:09:19 Connecting to MariaDB server host: mysql, user: root, password: set, port: not set, socket: /run/mysqld/mysqld.sock
...
[00] 2026-01-30 10:09:26 completed OK!
/backup_mariadb/
/backup_mariadb/backup-my.cnf
/backup_mariadb/ibdata1
zstd: error 25 : Write error : No space left on device (cannot write compressed block)
/bin/tar: /backup/backup_mariadb.tar.zst: Wrote only 4096 of 10240 bytes
/bin/tar: Child returned status 25
/bin/tar: Error is not recoverable: exiting now

---

echo $?
0

Which branch are you using?

master (stable)

Which architecture are you using?

x86_64

Operating System:

Not relevant

Server/VM specifications:

Not relevant

Is Apparmor, SELinux or similar active?

Not relevant

Virtualization technology:

Not relevant

Docker version:

Not relevant

docker-compose version or docker compose version:

Not relevant

mailcow version:

2025-12a

Reverse proxy:

Not relevant

Logs of git diff:

Not relevant

Logs of iptables -L -vn:

Not relevant

Logs of ip6tables -L -vn:

Not relevant

Logs of iptables -L -vn -t nat:

Not relevant

Logs of ip6tables -L -vn -t nat:

Not relevant

DNS check:

Not relevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions