This simple script creates a backup of every MySQL database and compresses it.
- Load password from config file
- Export functions and triggers in .sql files
- Compress backups with gzip
- Database exception list
- Organized backups folder by date backup/YYYY/MM/DD/
php backup-db.php
Run every day at 12 am
* 0 0 * * * cd /var/www/cron/ && php backup-db.php
- Clone the repository
- Add execution permision
chmod +x backup-db.php
- Copy .dist files:
cp config.php.dist config.php
cp mysql.conf.dist mysql.conf
- Set your user and password in config files.
- Add crontab configuration:
crontab -e