MySQL/MariaDB Backups Scheduling

Using this instruction you can easily schedule the automatic backup of a MySQL or MariaDB database.

  1. Create environment
    1. Log into the
      Jelastic Manager
    2. Click Create environment.

    3. In the Environment topology dialog pick MySQL as a database you want to use. Then set the cloudlet limit, state the environment name and click Create.

    4. mysql event scheduler

    5. Wait just a minute for your environment to be created.

    6. event scheduler

    7. Check your e-mail - your inbox should have a message from Robot@jelastic with database login and password.

  2. Setting up backups
    1. Click Config button next to your database.

    2. manage database

    3. In the opened configuration tab open mysql file in the cron folder.

    4. managing database

    5. In the opened file you'll see three samples of the cron parameters configurations:

      • for backup of several DBs (if you created them through the db admin panel):

        #0 1 * * * /var/lib/jelastic/bin/ -m dump -u USER -p PASSWORD -d db1[,db2,db3....]

      • for separate DB tables backup:

        #0 2 * * * /var/lib/jelastic/bin/ -m dump -u USER -p PASSWORD -d db -t table1[,table2,table3....]

      • for the whole DB backup:

        #0 3 * * * /var/lib/jelastic/bin/ -m dumpall -u USER -p PASSWORD

      Note: If your PASSWORD contains special characters, it should be included in the double quotation. Also, due to the cron specifics, you need to provide additional escaping for the % symbol by adding a backslash before it, for example -p "passw\%rd".
    6. Choose the one you need and specify your custom configurations:

      • frequency of the script evoking (using cron settings);
      • the path to the default script (available for MariaDB and MySQL) or to your own (you can upload it to the scripts folder): /var/lib/jelastic/bin/{script_name}
      • your database username and password (you received them in the email after adding database to the environment);
      • if you want to backup several databases or some separate tables, then enter their names separated by commas.

      For example, if you want to backup your database every 10 minutes with a help of the default script, then the string can be as following:

      */10 * * * * /var/lib/jelastic/bin/ -m dumpall -u root -p GGddHYJ

      database manage

    7. Save your settings!

  3. Checking backups
    1. Wait the time of backup you've scheduled while setting.
    2. Navigate to Configuration tab and open backup folder (/var/lib/jelastic/backup). There .bz2 files with all executed backups are stored.

  4. Download Backup
    1. Install FTP for your database. You can find instruction in FTP/FTPS Support guide.

    2. Connect to the MySQL/MariaDB database using any FTP client (e.g. FileZilla) and download your backup .bz2 file.

  5. Restore Database
    1. Access phpMyAdmin with the credentials you've got after adding DB node.

    2. Navigate to the Import tab and browse the backup .bz2 file. Click Go.

    3. When the import is successfully finished you will see your database with all the data restored.

    That's all! Now you can be sure that all your data is being saved periodically and can be restored or reused.