Solved

Can MySQL replication master-slave be used for backup?

Posted on 2011-10-01
3
746 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
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…

710 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