Live database backup
-
Hi,
Something bothers me about the backup. Cloudron can be used to launch a variety of services, and many applications require a database.
Some of these applications rely heavily on databases. Is it safe to backup these applications while they are running and the database is writing data?
For example, I installed Rocket Chat. Someone is always texting, and the database is always busy. What are the chances of the database getting corrupted during the backup in this case? -
Hi @njts,
database backup tools usually have mechanics to be "transaction safe" (MySQL for example has the "single transaction" parameter) meaning the backup is consistent to the moment the backup started.
-
The db dumps are atomic (it's a feature of the databases).
What's not atomic is if an app does not make database changes in a transaction. Or if it tracks state outside of the database. For example, if it writes some media file to filesystem and tracks something else in database. Outside of disk snapshots, there is no way to snapshot a database and filesystem at the moment in time. Disk snapshot of a database is not very portable and in most cases on cloud servers disk snapshots of specific paths are not an option.
I used to worry about this a lot back in the day
But hundreds of thousand of installation later, I can tell you that I have never hit this problem (the atomicity aspect).