Jump to content

MySQL Database Backup Cron Job


Nathan

Recommended Posts

  • Administrators

The most efficient way I have found to backup my databases on my Cpanel Linux system is using a MySQL dump via a cron job.

 

Here is the syntax:

 

/usr/bin/mysqldump -u username -ppassword databasename | gzip -c > /home/Digitize Design/public_html/_db_backups/`date "+\%Y\%M\%d\%H\%m"`.filename.sql.gz

 

 

All you need to do is replace "username", "password", "databasename", and the location of where to save the file. As you can probably tell it will also gzip the backup to save disk space.

 

Click here to view the article

Link to comment
Share on other sites

You can also make the date field dynamic.

 

Add date='date -I' to the start of the line then you can use the $date variable instead. This is what mine looks like and works perfectly.

 

date='date -I' ; mysqldump -u DBUSER -pDBPASSWORD DBNAME > /home/gadgetbi/public_html/BACKUP FOLDER/dbbackup_$date.sql ; gzip /home/gadgetbi/public_html/BACKUP FOLDER/dbbackup_$date.sql

Link to comment
Share on other sites

How did you do it then?

Manually just backed it up few times a week before installing a new mod or before making any change. I know its lacking on security it can always happen that my forum goes down but I didn't know i was able to do that with cron jobs I used cron jobs only for my php mafia script once so knew they do a few things but didn't know that they do this ;)
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...