1. Home
  2. Docs
  3. Backups
  4. How to set up
  5. Database Backups

Database Backups

Let\’s choose how to set up your database backups!

At this time, Sucuri Backups only supports MySQL databases.

Auto Detect

This option will have our platform try to detect the database configurations automatically as long as you are using a popular CMS-type websites such WordPress. This is the default method and selected automatically when adding a new Backup subscription.

No Database

If you have no database to back up simply click on the option and proceed.

Manual

Choose this option to set up your database connection manually.

Screenshot

  1. Click Add New Database

Screenshot

NOTE: When selecting connection type, use "Local using PHP" only if a direct connection to your MySQL is not available.

  1. Enter in your Database connection information into the form and click Save.

Cron Job

If you wish to set up backups via a Cron Job / Scheduled Tasks, we do provide that option. This is the cron template that we use:

mysqldump -h'localhost' -u'user' -p'password' db_name | gzip > path_to_public_folder/sucuri-backups/db_name-sucuri-db-dump-gzip-1432041495-$(echo -n $(date) | md5sum | awk {'print $1'}).gz

To configure the Cron Job, you must perform the following steps:

1) Create a directory named sucuri-backups on the website root directory;

2) Copy the Cron Job template to a text editor so you can replace the values safely before copying over to your hosting panel Cron Job / Scheduled Tasks page;

3) Replace the missing information from the Cron Job template. Let\’s assume your database name is johnbakery_wordpress, the database user is johnbakery_user, password is s$sNhC@shtnBY and your website public folder is located at /home/johnbakery/public_html.

Step by step, we will change each value.

a) First, let\’s update the database name. Remember, the template was:

mysqldump -h'localhost' -u'user' -p'password' db_name | gzip > path_to_public_folder/sucuri-backups/db_name-sucuri-db-dump-gzip-1432041495-$(echo -n $(date) | md5sum | awk {'print $1'}).gz

After updating the database name, it became:

mysqldump -h'localhost' -u'user' -p'password' johnbakery_wordpress | gzip > path_to_public_folder/sucuri-backups/johnbakery_wordpress-sucuri-db-dump-gzip-1432041495-$(echo -n $(date) | md5sum | awk {'print $1'}).gz

_NOTE: There are two "dbname" on the template, one before the | symbol and one after /sucuri-backups/. You must update both.

b) It\’s time to update the user, the Cron Job will now be:

mysqldump -h'localhost' -u'johnbakery_user' -p'password' johnbakery_wordpress | gzip > path_to_public_folder/sucuri-backups/johnbakery_wordpress-sucuri-db-dump-gzip-1432041495-$(echo -n $(date) | md5sum | awk {'print $1'}).gz

c) Let\’s set the password:

mysqldump -h'localhost' -u'johnbakery_user' -p's$sNhC@shtnBY' johnbakery_wordpress | gzip > path_to_public_folder/sucuri-backups/johnbakery_wordpress-sucuri-db-dump-gzip-1432041495-$(echo -n $(date) | md5sum | awk {'print $1'}).gz

d) Last, but not least, update the website public folder:

mysqldump -h'localhost' -u'johnbakery_user' -p's$sNhC@shtnBY' johnbakery_wordpress | gzip > /home/johnbakery/public_html/sucuri-backups/johnbakery_wordpress-sucuri-db-dump-gzip-1432041495-$(echo -n $(date) | md5sum | awk {'print $1'}).gz

4) Add the updated template to your hosting panel Cron Job / Scheduled Tasks page. You should set the Cron Job to run once a day, preferably at a low traffic hour such as 0 AM your timezone.

You can backup more than one database as long as you setup a Cron Job for each.

Sucuri Backups application takes care of all housekeeping and will delete previous archives after the new one has been downloaded. Using a cron job only requires space on your host server to save one database archive. The sucuri-backups folder will be configured to be acessible only by the Sucuri Backups server automatically.

In case the backup file is empty or missing tables, you can configure another Cron Job just for debugging, for example:

mysqldump -h'localhost' -u'johnbakery_user' -p's$sNhC@shtnBY' johnbakery_wordpress 2> /home/johnbakery/public_html/sucuri-backups/mysqldump-output.log

Remember to delete this "debugging" Cron Job once you finished analyzing the log.

If you are still not sure what do, please feel free to open a support ticket with the Sucuri team.

Was this article helpful to you?