My main concern is getting a proper backup, even more so than a temporary outage. The data is golden. I've been doing reading through the documentation and a lot of the backup strategies seem to be.
- Setup master-slave replica set.
- When you want to back up, stop replication on the slave to basically "freeze" it.
- Run your
mysqldump
or w\e you choose. - Restart replication and the slave will eventually catch up.
That's all well and good, but is there a theoretical off-chance that the slave could become corrupt (perhaps replication didn't happen right, or the slave disconnected from the replica set)? If so, I will unknowingly be taking corrupted or stale backups. What is the best strategy to avoid this? The only thing I could think of is:
- Stop the database service completely on master and slave. Pull them out of the replica set.
- Edit PHP config files to point to slave server.
- Start the slave (essentially the new master) as to avoid downtime during backup.
- Start the old master isolated and run your
mysqldump
- Stop both servers and somehow sync them back up to a consistent state (in case any writes happened on the old slave while the old master was backing up)
- Fix your conf files, start the old master as the master and your old slave as the slave.
This seems very convoluted, is there a better solution? I don't need multi-master. The reads & writes will happen on one server. The slave is just for failover purposes.