Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can MySQL replication master-slave be used for backup?

Posted on 2011-10-01
3
Medium Priority
?
762 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:Richard R
[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 2000 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:Richard R
ID: 36898380
Thanks.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

664 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