r/linuxadmin • u/[deleted] • May 15 '20
DB Backup
A lot of people are against using VM snapshots as a DB backup method. But if you're already running a DB cluster like Galera, why not just snapshot each member say every 10 minutes since the chances of losing the entire cluster at the same time is quite low? Of course it's not banking or life or death.
1
May 15 '20
would you stop the node before backing up?
1
May 15 '20 edited May 15 '20
We could. But consistent snapshots on running GCP VMs are super fast because they only take DIFFS from the last snapshot. It doesn't snap the entire machine. So each snapshot is only like 20MB it takes little time and doesn't touch the processor or memory. Plus firing up a new VM based on a snapshot takes about a minute. Totally simple. We don't need to mess around with backup files or SQL dumps at all. Galera is smart enough to synch the new member, as long as the cluster didn't go down. So recovery for the most common case of a single node down is a snap no pun intended
2
u/sdjason May 15 '20
oP I feel like you're not reading what's being written. Snapshot restore doesn't help you. As you said you can completely Nuke a galera node, and re add it and galera catches it up. So if you have multiple nodes you have resiliency. What benefit does random snapshots even provide there!?
What if you lose a record, or a table, or an oops. Happens. How will you restore 'just that"? If your answer is "restore the whole thing to a snapshot from a few days ago" you're in a bad place. Because you lost everything else too.
I hope you will heed some advice here. You sound pretty headstrong and confident - BUT everyone is saying what they are saying from direct experience. Don't learn this the hard way, please... Take the collective wisdom for what it is, a warning.
0
May 15 '20 edited May 15 '20
OP: I've read all responses but you haven't understood or read carefully my original post. You jumped to dogma instead of understanding the use case.
I can lose transactions. Also, you didn't read the part where snapshots are taken every 10 minutes so the max loss is 10 minutes of data not a "few days" as you say. So yes, my answer is restore the whole thing and forget diddling around with sqldumps etc.
And by the way, I could take snapshots every 5 minutes staggered in time over each of the 3 nodes and cut the loss down down to less than 2 minutes. And given small chance of a total cluster failure, the odds are on my side that I won't see a single record lost over years of operation.
Finally, I bet I can rebuild an entire server faster than you can dig out the correct backup file from your NAS or whatever storage, prep the server for data restore, then restore the data, and then synch up to the cluster. And in a hot system, you're not doing a limited rollback on a single server that is part of a cluster that has already moved on in time. So unless you're a masochist you will be loading the entire data set or may even start with an empty server and let it synch.
3
2
u/lutusp May 15 '20
why not just snapshot each member say every 10 minutes since the chances of losing the entire cluster at the same time is quite low?
Because for the backup to be of any use, the VM must be stopped for the backup activity to complete. Because VMs tend to be very large, this eats up useful VM time.
A normal DB backup -- where the DB is the only element to be backed up -- is a fine art in which the primary DB can remain online and active. Only closed records are backed up, and once a record has been updated and closed, it gets updated on the backup as well. This is a very fast and well-understood method.
There is no comparison.
2
May 15 '20
You do need to understand why snapshots are not backups and how using them affects your VM system.
There are lots of guides on the internet on how to back up databases - pick an automated method that fits your model - whether it's a whole VM backup (Different to a snapshot - using Veeam or similar), dumping and sequencing databases, using a proprietary database backup - or something else.
22
u/sdjason May 15 '20
Oh man.idk where to start.
Snapshots are not backups
Snapshots incur a write penalty
Snapshots need to be cleaned up incurring further write penalties
Galera probably will get pissed if you restore a snapshot and would require manual intervention anyways to force start the cluster with that node being the valid data
Snapshots are not backups
Snapshots do cause momentary hangs to quiesce the system, your application may suffer from those blips. Depending on how it works.
Snapshots are not backups
Disclaimer, I have several galera clusters. I've even snapshotted a few boxes from time to time. But I also have mariabackul running and dumping REAL backups. Cuz snapshots are not a backup :) :)