Score:0

Use snapshots to freeze a single database in MySQL

au flag

Various resources such as https://mariadb.com/kb/en/backup-and-restore-overview/ or https://www.thegeeksearch.com/how-to-backup-and-restore-mariadb-database/ describe how to backup the entire data of a MySQL instance. However, they all talk about the entire dataset across all databases.

I'd like to achive per-database snapshots (e.g. with LVM, KVM, qcow2 etc). However this may not be possible as it is my understanding that mariadb has some shared files across all databases.

In my dreams: Imagine the situation where applications A and B both connect to a single mariadb instance holding both corresponding databases A and B. Application A now runs a critical migration and I want to perform a quick (physical) snapshot before that. mysqldump would take hours, thus assume that I somehow managed to have mariadb write all information regarding database A (e.g. a.idb) to a special place such as an LVM volume. I simply lock my tables, snapshot that volume, unlock the tables and end up with a blazing-fast COW-based copy of my data. I run my migration, it blows up. Now the snapshot is restored and if this worked, I'd be back with my original data in a matter of seconds. Application B is not affected.

Now that's not reality as it seems. There is some info about recovering databases from a.idb and other files, e.g. https://symplecticgames.wordpress.com/2018/04/05/recovering-mysql-database-from-frm-and-idb-files/ but that's not exactly an in-and-out-job as would be having the ideal snapshot restore described above. The description even involves stopping the entire mariadb process.

An obvious solution would be to have a separate mariadb process with it's own complete dataset on a different special place such as an LVM volume. However that brings in the complexity of managing a potentially very high number of MySQL servers all running at the same time. While this could be automatized, it may not be ideal.

Is there some possibility to achieve or approximate the dream world described above?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.