Not logged in - Login

Linux - How to schedule an automatic backup for DB

Steps for scheduling a backup for MySQL database in Ubuntu:

  1. Write a script for the task.
    First install automysqlbackup:

    sudo apt-get install automysqlbackup

    You can configure the options using

    sudo nano /etc/default/automysqlbackup

    Now you can try and run automysqlbackup and create the script

    sudo automysqlbackup

    Great! Now we've got the script ready at "/usr/sbin/automysqlbackup". Lets make a folder to put our backups in

    sudo mkdir backups

  2. Schedule a job task in cron. ** So now that we have our backup process nailed down, let’s make sure this starts every day at midnight

    crontab -e

    And add the lines:

    # Start backing up our MYSQL at midnight
    0 0 * * * /usr/sbin/automysqlbackup
    # 10 minutes later, start our script
    10 0 * * * /fullBackup.sh

    And there you have it, your server is now backed up locally and also on your FTP server.