Backing up the database and storing your backups in a safe place protects you from any possible data loss. In order to minimize the risk of catastrophic data loss you have to create a backup copy of your databases to preserve modifications to your data on a regular basis. A well-planned backup and restore strategy are irreplaceable tools for database protection against data loss caused by a wide variety of failures.
Having valid database backups, you can easily recover your data from a number of failures, such as: media failure; user errors, for example, dropping a table by mistake; hardware failures, for example, a damaged disk drive or permanent loss of a server; natural disasters; also backups of a database are useful for routine administrative purposes, such as copying a database from one server to another, database mirroring and archiving.
Scheduled backups are backups of data that takes place automatically according to a schedule and without additional computer or user presence. The advantage of using scheduled database backups is obvious: instead of manual backups, a backup process can be run during off-peak hours when data is unlikely to be accessed, precluding or reducing the impact of backup window downtime.
The tutorial below explains how to backup your Jelastic databases automatically with help of cron scheduler.
1. Log into the Jelastic dashboard and click Create environment.
2. In the Environment topology window select MySQL as your database. After that set the cloudlet limit, specify name of your environment and click Create.
In a minute your environment will be created.
3. Check your e-mail: you’ll receive a message from Robot@jelastic with database credentials.
Setting up backups
1. Click on the Config button next to your database.
2. In the opened configuration tab navigate to the cron folder and open mysql file.
3. In this file you’ll see three samples of the cron parameters configurations:
for backup of several databases (if you created them through the database admin panel):
#0 1 * * * /var/lib/jelastic/bin/backup_script.sh -m dump -u USER -p PASSWORD -d db1[,db2,db3....]
for separate database tables backup:
#0 2 * * * /var/lib/jelastic/bin/backup_script.sh -m dump -u USER -p PASSWORD -d db -t table1[,table2,table3....]
for the whole database backup:
#0 3 * * * /var/lib/jelastic/bin/backup_script.sh -m dumpall -u USER -p PASSWORD
4. Choose the one you need and specify your custom configurations:
frequency of the script evoking;
the path to the default script or to your own (you can download it to the scripts folder);
your database username and password (you received them via 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 look like following:
*/10 * * * * /var/lib/jelastic/bin/backup_script.sh -m dumpall -u root -p GGddHYJ
5. Don’t forget to save your settings!
1. Wait for the time of backup you have scheduled.
2. Navigate to Configuration tab and open backup folder. There .bz2 files with all executed backups are stored.
That’s all for today! Now you can gain a number of benefits by backing up important information and be sure that all your data is being saved periodically and can be restored or reused.