Auto Backup Process for Ubuntu MySQL using mysqldump and Cron

  • to enable mysqldump command on ubuntu xampp
    export PATH=$PATH:/opt/lampp/bin
  • Create file backup.sh
    sudo nano /var/www/backup.sh
  • Put content
#!/usr/bin/env bash

/usr/bin/mysqldump -u root -pABCD --databases lacrm_tejimandi | gzip > /var/www/Backups/lacrm_tejimandi-`date +%F-%T`.sql.gz
  • replace ABCD with DB Password
  • Give Proper Permissions
    sudo chmod -R 755 /var/www/backup.sh
  • Setup Cron Job for Backups
    env EDITOR=nano crontab -e
  • Put content
    0 08 * * * /var/www/backup.sh
    0 12 * * * /var/www/backup.sh
    0 15 * * * /var/www/backup.sh
    0 20 * * * /var/www/backup.sh
Share

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.