Solved

Can MySQL replication master-slave be used for backup?

Posted on 2011-10-01
3
732 Views
Last Modified: 2012-05-12
Hi,

I've setup a mysql replication environment, master-slave (2) servers.
When something is written in the master it will replicate in the slave as suppose to.

My question is: 1) Can I use this setup for backup? Meaning, if the master database or a table gets corrupted, can I do a dump from the Slave and import into the Master server? Or in case the database get's hacked or someone deletes all or some tables, are there ways to restore it from the slave?
2) Or if the above is not possible, is there a way to setup a third server maybe (slave) to just do live backup and if something database/table gets deleted it wouldn't change on the backup server. Or maybe set it up to sync every 1-2 hours?

Or everything that happens with the Master will happen as well to the Slave, being good or bad?

I'm trying to not use mysqldump and hot copies of /var/lib/mysql

Please clarify it for me.

Thank you very much!
0
Comment
Question by:rr100
3 Comments
 
LVL 38

Expert Comment

by:Aaron Tomosky
ID: 36897905
This setup if if hardware or network connection fails on server1 them you can use server2. Like a hot spare. However this will not protect you against deletions as you suspect.
0
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 36897926
The slave is your best protection in case something happens to the hardware or operating system of the master such that you cannot use it.  It only takes a few commands to promote the slave to become the new master then you just need to point your applications to use it.  BUT everything that happens to the master that's due to a SQL statement will happen to the slave shortly.  Somebody drops a table, it will also gets dropped in the slave.  

So no, having a slave DOES NOT exempt you from having backups.  Yes you can set up a third server then turn the slave process on and off, but what will happen to you if a hacker attacks the master at exactly the time you have syncing turned on?  Always have a backup process in place.  Using mysqldump to backup takes a lot of time for big databases, and longer than that to restore, so I recommend copying the whole /var/lib/mysql of the slave then just binary logs from the master.  At my work I always have a full backup of /var/lib/mysql of the past day, so that in case something happens on the current day, I can do a point in time recovery using that as base then replay the binary logs up to just before the problem happened.
0
 
LVL 2

Author Closing Comment

by:rr100
ID: 36898380
Thanks.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now