Sucuri Docs > Backups > How to set up > 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 website CMS such WordPress. This is the default method and will be 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

Enter your database connection information into the form and click Save.

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

Cron Job

If you wish to set up backups via a Cron Job or Scheduled Task, 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 into a text editor so you can replace the values safely before copying them over to your Cron Job or 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 "db_name" 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) Finally, 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 or Scheduled Task page. You should set the Cron Job to run once a day, preferably at a low traffic hour such as 0 AM your local timezone.

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

The 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 automatically configured to be acessible only by the Sucuri Backups server.

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?