MySQL databases backup made simple

It's a bash program to backup all needed databases on my system. It uses thy MySQL database to get information what and when to backup. It is calling the mysqlbackup command so it's not very good for large databases.

Post is split this post in two parts: Installation in 4 steps and Description.

Installation in 4 steps

Step 1

  1. Create database to maintain the database backup. In this example – „manage“
  2. Grant all needed privileges to the desired user. In this example – „manage_user“, „manage_pass“

Step 2

Download and unpack the installation files

tar xvz backub_db.tgz

Configure the ini file (BackupDB/config/config.ini)

Step 3

Load backup table definition

mysql -u manage_user -pmanage_pass manage < BackupDB/sql/backup.sql

Insert rows with databases you want to backup (user has to have privileges sufficent to provide mysqldump action)

INSERT INTO `backup` (`frequency`,`name`,`user`,`password`) VALUES ('daily','backup_db_name','backup_db_user','backup_db_pass');

Step 4

Configure cron. Just enter crontab -e and add following lines:

10 1 * * *    /path/to/the/directory/BackubDB/bin/mysql_backup.sh daily
10 2 1 * *    /path/to/the/directory/BackubDB/bin/mysql_backup.sh weekly
10 3 1 1 *    /path/to/the/directory/BackubDB/bin/mysql_backup.sh monthly

Your backups will be stored in the BackupDB/backup/mysql/ directory as backup_db_name_YYYY-DD-MM_HH-SS.sql

Upgrade

There may be many ways to make this code better.

One may use the backup table as a part of bigger project. It's just important to have these fields in the backup table:

`frequency`     ENUM('daily','weekly','monthly') DEFAULT 'daily',
`name`          VARCHAR(255),
`user`          VARCHAR(255),
`password`      VARCHAR(255),
`last_backup`   DATE DEFAULT '0000-00-00'

The other solution is to use external backup. There will be a need to add server field to backup table and change the lib/backup.sh and bin/mysql_backup.sh to use it.

Links

Ini parser code

Trackback URL for this post:

http://piotr.zalewa.info/trackback/51

Comments

hasdress (not verified) 1970, January 1 - 00:00
Wireless Home Security (not verified) 1970, January 1 - 00:00

I am on this website because I want to understand which Wireless Home Security providers must I choose.

Online Backup (not verified) 1970, January 1 - 00:00

Are willing to recover your data with military-grade security? Thence, Online Backup options are a good resolution for you. Furthermore, you will sleep well all nights long knowing that your files are secured.

cheap moncler (not verified) 1970, January 1 - 00:00

I really have learned a lot from you.Thanks for sharing. So many people have come to your blog.

cartier love (not verified) 1970, January 1 - 00:00
cartier necklace (not verified) 1970, January 1 - 00:00
buy ugg (not verified) 1970, January 1 - 00:00

Thanks for sharing this information with us. I am very impressed with your blog post. I appreciate your work. Your blog is really very informative.

coach purses outlet (not verified) 1970, January 1 - 00:00

It sounds great!!!

banner designing (not verified) 1970, January 1 - 00:00

Do you realize what can get a lot of customers to your website? A progressive banner designing company can definitely advertize your web business!

London escort service (not verified) 1970, January 1 - 00:00

Are you willing to be safe when utilize escort services? London escort service will provide high quality services and sheer security for good costs.

Juicy Couture Sale (not verified) 1970, January 1 - 00:00

Fantastically blossom in highlighting color collections, fascinatingly high-shine in girly candied, graceful yet luscious designs, Juicy Couture handbags always catch girls eye balls and cater an instant stylish taste on their first sight. Also superiorly textured in luxurious velour or premium leather, edgy yet demure in styles, and vigorously flattering in color choices, Juicy Couture bags fit any outfit perfectly with a fabulously polished addition, which wins a lasting appreciation of the holders! If you are wondering a pretty Juicy bags online, you don’t have to go any further, Juicy Couture outlet online store here has got a dazzling series of bag options online! http://www.ju­icycouturelive­.com

Juicy Couture Outlet (not verified) 1970, January 1 - 00:00

Ralph Lauren outlet store online are committed to all customers' complete satisfaction with her ebullient, considerate and credible services together with quality guaranteed Ralph Lauren polo men's shirts. Here Ralph Lauren polo shirts are in all purposes to meet your demands from utility to fashionability. http://www.po­loralphlauren-sale.com

Cheap Nike free run (not verified) 1970, January 1 - 00:00
Anonymous (not verified) 1970, January 1 - 00:00

Uncover the best Wedding accessories to compliment your Wedding Dress is. We're here to make your big day even much more lovely.

Guess Shoes online (not verified) 1970, January 1 - 00:00

I had already downloadd it, so thanks for the show! http://www.bu­ycheapguess.org http://www.bu­ycheapguess.org

Tantric Massage (not verified) 1970, January 1 - 00:00

I want to choose some super mix of vivacity and satisfaction. I think, a Tantric Massage will be exactly what I search for!

direct mail letter (not verified) 1970, January 1 - 00:00

No one knew just about my site until I became to utilize direct mail letter service. That raised my site a lot!

dress (not verified) 1970, January 1 - 00:00
AustinLelia (not verified) 1970, January 1 - 00:00

Some gus guess that plagiarized content cannot be seen by anyone. I claim that plagiarism detector aids to determine any hints of plagiarized papers.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.