Announcement

Collapse
No announcement yet.

Cron Job Setup To Send database backup to Gmail Account

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cron Job Setup To Send database backup to Gmail Account

    I have this setup on one of my servers. It is a lifesaver. First thing to do is to make a bash script. In the bash script was the following code:

    Code:

    *!/bin/sh
    ******
    * first make a mysqldump of all databases, and tar and zip it
    ******
    mysqldump --add-drop-table -u user_name -p password --all-databases | tar -vxzf > backup.sql.tar.gz
    ******
    * next email it
    * The echo at the start of the last line adds a blank into the body of the
    * mail being set out.
    ******
    echo | mutt -a backup.sql.tar.gz -s “daily backup of database” [email protected]
    ****
    * finally, delete the backup from your server
    ****
    rm backup.sql.gz

    Secondly chmod +x the script to make it executable,
    next, just add a daily cron job to call the script and that's it.
    UK VPS Hosting || Dedicated Server || Cloud Hosting
    Looking for extra income ?
    Join our Webhosting UK Affiliate Program and earn upto 60% commission (up to £100) per referral.
Working...
X