MySQL Backup Automation Cron Checklist

halfbrain_logo512adminJune 19, 2026
3 lượt xem

MySQL Backup Automation Cron Checklist

Manual database backups are easy to forget. A system admin needs automated backups with logs, retention, offsite copy, restore testing and alerts when the job fails.

Core principle

Backup automation is a production workflow. It needs schedule, credentials, storage, verification, retention and monitoring.

Checklist

  1. Choose databases to back up.
  2. Create a backup script with safe permissions.
  3. Use a limited database backup user if possible.
  4. Compress backup files.
  5. Name backup files with date and database name.
  6. Redirect output and errors to logs.
  7. Schedule backup with cron.
  8. Apply local retention policy.
  9. Copy backup offsite if possible.
  10. Test restore regularly.

Reusable lesson

This applies to WordPress, n8n, analytics databases, app databases, staging refreshes and disaster recovery planning.

Checklist Type Backup & Recovery
Level Intermediate
Risk Level High Risk
Estimated Time 60–150 minutes

When to Use This Checklist

Use this checklist when automating MySQL or MariaDB backups for websites, apps or automation systems.

Required Tools

SSH access, mysqldump, cron, backup folder, offsite storage, restore test database, log file path

Before You Start

Do not consider backup automation complete until restore has been tested from an automated backup file.

Structured Checklist Steps

  1. Select databases.
  2. Create backup script.
  3. Use backup user.
  4. Compress backup.
  5. Name files consistently.
  6. Log output.
  7. Schedule cron.
  8. Apply retention.
  9. Copy offsite.
  10. Test restore.

Verification Steps

  1. Cron creates backup file.
  2. Backup log is readable.
  3. Old backups are cleaned safely.
  4. Offsite copy works if configured.
  5. Restore test succeeds.

Common Mistakes

  • No restore test.
  • No error log.
  • Backup stored only on production disk.
  • No retention policy.
  • Plaintext credentials exposed with weak permissions.

Related Commands

mkdir -p /backups/mysql
mysqldump -u db_user -p database_name | gzip > /backups/mysql/database_name-$(date +%F).sql.gz
crontab -e
ls -lh /backups/mysql
find /backups/mysql -type f -mtime +14 -delete
gunzip -c backup.sql.gz | mysql -u db_user -p restore_test

Share:

Disclaimer: The guides, checklists, commands, and examples on HalfBrain.net are provided for educational and operational reference only. Server environments, hosting providers, software versions, security settings, and WordPress configurations can vary, so you should always review commands before running them on your own system. We do our best to keep the content accurate and useful, but we cannot guarantee that every command, configuration, or recommendation will fit every environment. Always back up your website, database, and server configuration before making changes. HalfBrain.net is not responsible for data loss, downtime, security incidents, misconfiguration, or other issues that may result from applying the information on this website. Use the material at your own discretion.

Leave a Reply

Your email address will not be published. Required fields are marked *