Some backup tools and scripts process large amounts of data in memory instead of writing it directly to disk. When the database becomes larger, the backup process may consume excessive RAM and trigger the Linux Out-of-Memory (OOM) killer.
To investigate:
Check whether the backup process was killed:
journalctl -k | grep -iE "oom|killed process"
Check available memory:
free -h
Use mysqldump with output redirected directly to a file:
mysqldump --single-transaction DATABASE_NAME > backup.sql
For large databases, consider using compression:
mysqldump --single-transaction DATABASE_NAME | gzip > backup.sql.gz
Avoid loading the entire SQL dump into a programming language's memory.
Monitor memory consumption during scheduled backups.
For very large databases, consider physical backup tools such as Percona XtraBackup, where supported by your database version and configuration.