Simple Mysql Database Backup Weekly Daily Monthly

Create 3 script

daily.sh
weekly.sh
monthly.sh

daily.sh
======

#!/bin/bash

#this is run by the root crontab

mysqldump -ubugs_db -pucb1986 bugs_db > /root/backups/daily/bugs_db.sql

weekly.sh
=======
#!/bin/bash

#this is run by the root crontab

mysqldump -ubugs_db -pucb1986 bugs_db > /root/backups/weekly/bugs_db.sql

monthly.sh
========

#!/bin/bash

#this is run by the root crontab

mysqldump -ubugs_db -pucb1986 bugs_db > /root/backups/monthly/bugs_db.sql

Give execute permission to scripts

chmod +x daily.sh
chmod +x monthly.sh
chmod +x weekly.sh

then move scripts
cp daily.sh /etc/cron.daily/
cp weekly.sh /etc/cron.weekly/
cp monthly.sh /etc/cron.monthly/

Leave a Reply

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