Solved

Can MySQL replication master-slave be used for backup?

Posted on 2011-10-01
3
744 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 39

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Read about achieving the basic levels of HRIS security in the workplace.
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…

832 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