Tutorial

One of the most important things you can do for your Dolphin is backup the database regularly. The more often the better actually. Database backups and downloads are generally compressed so they tend to be relatively small and fast.

If you are like most people, at first you do a good job at keeping these up. After while you get lazy, forget, or just don't care. Until one day something does happen and you realize how important these are and how badly you wish you had a recent backup.

This fairly simple to install script will backup your mysql databases to your hosting/server and send them to you by email. This giving you 2 copies of your database. One on the server and one in your email. That way if something happens to your email or host/server you will have an alternated backup. You should choose an email address to send to that is not associated with your host/server. It should be a different email altogether so it will be stored and sent through a totally unique email/host/server/address.

You can decide how often you want this to happen as this runs by cron. Have it 1x per day, every 12 hours, or whatever you wish. For small-medium sites 1x per day is usually sufficient. For bigger sites or sites with a lot of activity 2x per day or every 12 hours, but it's all up to you.

You can specify a time with cron such as:
35 1 * * *
-This would be every night at 1:35 am.

0 */12 * * *
-This would be every 12 hours

0 */8 * * *
-This would be every 8 hours

 



This guide and info is based on the popular cpanel hosting control panel, but you can easily adjust it for other types of hosting. Usually just by changing the paths/locations.

Download the original backup script from sourceforge here:
http://sourceforge.net/project/showfiles.php?group_id=101066

Or Download one from be with most of it already filled out for you for cpanel.
You will only need to make a few adjustments to reflect your host and database.
http://www.dialme.com/guides/mysql-back/mysqlbackup.zip

As always before messing with anything you should download a backup of your database just in case you do something wrong or delete something by accident.



First create a new database user using cpanel's mysql database feature.
Example:
Database User
youraccount_mysqbak
Database Password:
Password


Then add the database user to the the database you wish to autobackup
Example:
Add database user:
youraccount_mysqbak <---the new database user you just created
To:
youraccount_dolphin <---your current dolphin database



Now extract and open mysqlbackup.sh from the .zip file and edit the following to reflect your cpanel account name/paths and database names

Find:
# Username to access the MySQL server e.g. dbuser
USERNAME=youraccount_mysqbak

Change youraccount_mysqbak to your cpanel account name and the new mysql database user you just created



Find:
# Username to access the MySQL server e.g. password
PASSWORD=Password

Change Password to your actual database user password of the database user you just created


Find:
# Backup directory location e.g /backups
BACKUPDIR="/home/youraccount/backs/"

Change the "youraccount" part to your actual cpanel account name


Find:
# Email Address to send mail to? (user@domain.com)
MAILADDR="you@yoursite.com"


change "you@yoursite.com" to your actual email address you wish to use for reports and files. This should not be an email that resides on this same host/server email. It should be a unique location.



That should be all you need to update. Save file and upload to your host/server.
--You can look through the file for other things to edit and change, but make sure you know what you are doing.

Upload mysqlbackup.sh above your public_html directory, so it is not accessible by general web visitors.
File should be chmod/permission of 755

Create a folder/directory above public_html called backs and chmod/permission of 777 so it is write-able by the server. This is where the backups will be stored on the host/server.

Example:
/home/youraccount/mysqlbackup.sh
/home/youraccount/backs

***DO NOT put them in public_html or they will be accessible by web browsers:
---Wrong
----/home/youraccount/public_html/mysqlbackup.sh
----/home/youraccount/public_html/backs


***These are above your public_html folder so they are not directly accessible by a web browser. Make sure you put them in the right location. DO NOT put them in public_html, if you do they will be accessible by a web browser.




Set cron in your host control panel:

Minute Hour Day Month Weekday            Command
0      3    *   *     *                /home/youraccount/mysqlbackup.sh

Change the command path /home/youraccount/mysqlbackup.sh to your actual cpanel account name and path to the script.

Example:
/home/msitecom/mysqlbackup.sh

Change cron time to your desired time. The above example 0 3 * * * will run every night at 3 am.

You may wish to test this to make sure it's working. To do so you can temporarily set the cron to go off every 1 minute. You should receive an email to the address you specified with your mysql backup files.

To do so set cron to:
Minute Hour Day Month Weekday            Command
*      *    *   *     *                /home/youraccount/mysqlbackup.sh

Allow a minute or two to go by and if all is well you should receive an email with your backup database.

Now be sure to change the cron back to 3 am or to your desired time. You do not want to keep getting a backup every minute and save the cron.

If you did not receive an email or two, review all your settings and changes and try again.

You can use this same script to auto-backup additional databases if you have more. Just add the your backup database user you created to any other databases you have. You will then receive them by email and a copy in the backs directory/folder.

As time goes by you will get a daily, weekly, and monthly copy in the backs directory/folder as well.

Pretty cool!! And a big time saver too!!

 

 
Written By
Tutorial by: Jeremy LeSarge (AKA Ray)

I am the owner and administrator of DialMe.com. I write Tutorials for Boonex Dolphin as well as tips and resources surrounding website programming and development. I enjoy working with WordPress, SEO, and Web Hosting / Servers. I also maintain a WordPress Blog here on this site where you will find a variety of technology and webmaster resources.

Actions
Recommend
Sponsored Links