Backup File Zero Bytes: Detect Empty Backup Files
Your backup job completes, but the backup file is zero bytes. Learn how to detect and prevent zero-byte backup files.
Why Backup Files Are Zero Bytes
Backup files can be zero bytes:
- Backup command fails but creates empty file
- Disk space runs out during backup
- File permissions prevent writes
- Backup process is killed
- Source data is empty
Without checking file size, you might think backups are working when they're actually zero bytes.
How to Detect Zero-Byte Files
Always check file size after backup creation. Verify the file is not zero bytes. The check must be inside your backup script.
Bash Example: Check File Size
#!/bin/bashBACKUP_FILE="/backups/db-$(date +%Y%m%d).sql.gz"pg_dump mydb | gzip > "$BACKUP_FILE"# Get file sizeFILE_SIZE=$(stat -c%s "$BACKUP_FILE" 2>/dev/null || echo 0)# Single ping with file size in payload# In DeadManPing panel: set validation rule "size" > 0# Panel will automatically detect if size is 0curl -X POST "https://deadmanping.com/api/ping/backup-daily?size=$FILE_SIZE"Python Example: Verify File Size
import osimport subprocessimport requestsbackup_file = "/backups/db-backup.sql.gz"subprocess.run(["pg_dump", "mydb"], stdout=open(backup_file.replace('.gz', ''), "w"))subprocess.run(["gzip", backup_file.replace('.gz', '')])# Get file sizefile_size = os.path.getsize(backup_file) if os.path.exists(backup_file) else 0# Single ping with file size in payload# In DeadManPing panel: set validation rule "size" > 0# Panel will automatically detect if size is 0requests.post(f"https://deadmanping.com/api/ping/backup-daily?size={file_size}")Monitoring Zero-Byte Backup Files
After adding zero-byte checks to your backup script, use a dead man switch to monitor whether the check completed successfully. If your script detects a zero-byte file and exits with error code, the ping never arrives, and you get an alert.
Working Examples
See complete, working code examples in our GitHub repository:
View Examples on GitHub →Start Detecting Zero-Byte Backups
DeadManPing monitors whether your backup file verification completes. Set up monitoring in 2 minutes, get alerts when backups are zero bytes.
Start Monitoring FreeRelated Articles
Learn more about cron job monitoring and troubleshooting:
Detect Empty Backup File
How to detect when backup files are empty or zero bytes.
Detect Empty Backup File Cron
How to detect when cron backup jobs create empty files.
Verify Backup File Size
How to verify backup file sizes are within expected ranges.
Backup Monitoring Service
Backup monitoring that doesn't touch your execution.