DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How to Repair Corrupt MySQL Database Tables Step-by-Step
  • How to Restore a Transaction Log Backup in SQL Server
  • Point-In-Time Recovery (PITR) in PostgreSQL
  • Harnessing the Power of AWS Aurora for Scalable and Reliable Databases

Trending

  • Grafana Loki Fundamentals and Architecture
  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • How to Build Local LLM RAG Apps With Ollama, DeepSeek-R1, and SingleStore
  • How To Develop a Truly Performant Mobile Application in 2025: A Case for Android
  1. DZone
  2. Data Engineering
  3. Databases
  4. Schedule Backups for MySQL and MariaDB Databases

Schedule Backups for MySQL and MariaDB Databases

In this article, we’ll examine how to create a backup schedule and offer hints for better data scheduling and restoring.

By 
Gleb Antonov user avatar
Gleb Antonov
·
Updated Nov. 05, 19 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
18.6K Views

Join the DZone community and get the full member experience.

Join For Free

schedule backups logo

MySQL and MariaDB

Have you ever felt a moment of panic when you realize that your data might be lost? Human errors, malicious attacks, systems crash, or disasters happen when least expected. So it is highly important to always be prepared for such situations by keeping up-to-date backups that can help with data recovery. Automated backups ensure in-time refreshment of the data copies and eliminates the need for manual tracking and setup. In this article, we’ll examine how to create a backup schedule and offer hints for better data scheduling and restoring.

You might also like:  PostgreSQL Backup and Recovery Automation

Jelastic PaaS provides a convenient and straightforward script for backing up the stored data on the MySQL and MariaDB database nodes. Thus, the process is as simple as providing the required parameters and can be accomplished in a matter of minutes. No specialized knowledge is needed — just follow the setup steps to configure the appropriate cron expression.

Set Up Database Backups

For this tutorial, we’ll use the default backup script provided for the MySQL and MariaDB database nodes at Jelastic PaaS.

1. The source code of the script can be viewed directly within the dashboard. Click the Config button next to your database to open the built-in file manager and locate the /var/lib/jelastic/bin/backup_script.sh file.

schedule backups config

Tip: If you don’t have an environment with the MySQL or MariaDB database yet, follow the Database Hosting guide to create one.

2. To automate the script execution, we’ll use the cron scheduler available within the containers out-of-box. Open the /var/spool/cron/mysql file and provide a cron expression in the following format:

{frequency} {path-to-script} {script-parameters}

schedule backups cron

Here, you can use the commented examples as a template to define the required parameters:

  • {frequency} — sets the time of the script execution (see the guide linked above for details), e.g. */10 * * * *
  • {path-to-script} — points to the required script (default backup script is available for MariaDB and MySQL at /var/lib/jelastic/bin/backup_script.sh)
  • {script-parameters} — provides custom parameters for the defined script; the following ones are available in our case:
    • -m {mode} to backup whole or part of the database (“-m dumpall” or “-m dump” respectively)
    • -c {count} to set a number of the old backups to keep (e.g. “-c 3” to keep 3 old backups alongside the most recent one)
    • -u {user} and -p {password} to provide access credentials for your database (can be found in the after-creation email)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".
    • -d {databases} and -t {tables} to optionally specify list of databases (“-d db1[,db2,db3….]”) or tables within a database (“-d db -t table1[,table2,table3….]”) to backup

3. For example, if you want to back up a whole database every 10 minutes with the help of the default script, then the string should be as follows:

schedule backups script
*/10 * * * * /var/lib/jelastic/bin/backup_script.sh -m dumpall -c 3 -u root -p passw0rd

Save the settings to apply them.

4. To store data on some other node or the remote server, you can configure the appropriate mount point for your database.

Note: Any existing data in the mount point folder will be replaced with the files from the remote directory.

Alternatively, you can create a custom backup script, runnable from the remote server (database host, user, and password details will be required to establish a connection).

5. Wait for the script to be executed (depends on the configured cron frequency) and navigate to the /var/lib/jelastic/backup folder.

If the backup operation is successful, you’ll see the appropriate bz2 archive within the directory.

Download Backup of Database

There are multiple options to download a file from a Jelastic container:

1. The most straightforward variant is to use the configuration file manager directly in the dashboard.

schedule backup download copy

Locate the required file, hover over it, and select Download from the context menu.

2. Another option is to use the SFTP/FISH protocol connection.

The required access details can be viewed within the dashboard.

3. Also, you can install FTP add-on for your database to manage files via FTP.

Note: Public IP address is required for this option. If needed, it will be automatically attached to the node during add-on installation.

Based on your preferences, you can choose any of the proposed options.

Restore Database from Backup

In case of necessity, you can easily restore your database from the backups.

1. Access the phpMyAdmin panel with the credentials you’ve got in the email sent after the creation of a DB node.

2. Navigate to the Import tab, tick the Browse your computer option, and use the Choose File button to upload the required backup.

schedule backup import copy

Click Go at the bottom of the page.

3. When the import is successfully finished, you’ll see the appropriate notification in the admin panel.

That’s all! Now, you can be sure that data backups are made on a consistent regular basis and, in case of necessity, can be restored. Keep your data secure!

Database Backup MySQL MariaDB Schedule (computer science)

Published at DZone with permission of Gleb Antonov. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Repair Corrupt MySQL Database Tables Step-by-Step
  • How to Restore a Transaction Log Backup in SQL Server
  • Point-In-Time Recovery (PITR) in PostgreSQL
  • Harnessing the Power of AWS Aurora for Scalable and Reliable Databases

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!