Solved

Can MySQL replication master-slave be used for backup?

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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…

626 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