backup mysql database

cPanel, Industry leading hosting platform with world-class support.
Post Reply
ludolugo
Posts: 45
Joined: April 17th, 2020, 10:40 am

backup mysql database

Post by ludolugo »

Hi, how can i create a job to backup the mysql database, i have a hook pre job with a script to make the mysqldump mysql, but i can't control if the dump was ok or not so i would like to back it up with a job like the accounts job, so i can know if was successfull or not.

thanks
JetAppsAnton
Staff Member
Staff Member
Posts: 54
Joined: March 2nd, 2019, 2:40 am

Re: backup mysql database

Post by JetAppsAnton »

Hello ludolugo,

When configuring your Backup Job, you have the option to select which Backup Items you would like to backup with your Backup Job under the Backup Contains field. For your specific use case, you simply need to make sure you have Databases (and Database Users if preferred) selected, and all other items unselected when setting up your Backup Job. Please refer to the attachment below:
Capture1.PNG
Capture1.PNG (11.51 KiB) Viewed 633 times
When the Backup Job runs, JetBackup will then create a database dump on all databases associated with each account and include it on the account's backup(s) accordingly.

Please do note that if you have JetBackup installed on a standalone Linux server (no Panel), you would need to install and setup the "Manage Databases" plugin. You will then have the option to automatically associate available backups by the account prefix or manually set this up. For more information regarding this plugin and how to set this up, please visit: https://docs.jetbackup.com/v5.2/adminpa ... -databases

I hope you find the information above helpful and if you need any further assistance, please don't hesitate to reach out to our 24/7 support technicians at [email protected].

Best Regards,
Anton, JetApps Team
ludolugo
Posts: 45
Joined: April 17th, 2020, 10:40 am

Re: backup mysql database

Post by ludolugo »

yes, i know that, but i want to backup the main database, i mean the mysql database, this becasuse we've had some problems with mysql corruption, so it is more easy to restore with mysql databasa backup than restoring all databases.
JetAppsAnton
Staff Member
Staff Member
Posts: 54
Joined: March 2nd, 2019, 2:40 am

Re: backup mysql database

Post by JetAppsAnton »

Hello ludolugo,

Thank you for clarifying your use case, I see that you want the ability to back up the "root" mysql database and as you briefly touched on, there currently is no option to back this up in a Panel version of JetBackup 5 out-of-the-box. Just to add, we do have the ability to include "non-user" databases on the standalone Linux version of JetBackup 5 via our "Manage Databases" plugin.

With that said, may I urge you to open up a feature request at request.jetapps.com If you would like to bring this feature up for our development team's consideration. Opening feature requests and gaining a high number of votes helps our team gauge demand and determine which feature to try and promote for development.

Best Regards,
Anton, JetApps Team
CarlArnold
Posts: 1
Joined: February 3rd, 2023, 5:39 pm

Re: backup mysql database

Post by CarlArnold »

You can create a job to backup a MySQL database using the following steps:

1. Create a script to make the MySQL dump:

mysqldump -u [user] -p[password] [database_name] > [backup_file].sql

Replace [user], [password], [database_name] and [backup_file] with the appropriate values.

2. Create a shell script that will run the above command and store the exit code in a variable:

#!/bin/bash
mysqldump_result=$(mysqldump -u [user] -p[password] [database_name] > [backup_file].sql)
exit_code=$?

3. Create a job in Skyline that runs the shell script. The job should be set to run on a schedule that you determine. You can check the exit code of the shell script to determine if the backup was successful or not.

if [ $exit_code -eq 0 ]; then
echo "MySQL dump was successful"
else
echo "MySQL dump failed with exit code $exit_code"
fi

This way, you can have a job that performs the backup and provides feedback on whether the backup was successful for eventual CRM data enrichment.
Post Reply