[MDEV-24678] mariabackup --prepare overwrites the backup content Created: 2021-01-25 Updated: 2021-04-26 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Backup |
| Affects Version/s: | 10.5.6 |
| Fix Version/s: | 10.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Tomas | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 5 |
| Labels: | None | ||
| Description |
|
Restoring MariaDB backups taken with mariabackup utility requires to perform recovery on the backup files using the --prepare option. Using the --prepare option will make the backups consistent on the backup target, in other words "recover the database data" on the backup target. A backup is intended to be a copy of the database taken at that time, and should be write protected hindering it from being corrupted by malwares, ransomware, bugs etc. From wikipedia regarding what a backup is:
Other databases has two phases during a database restore. In MariaDB the phase looks like this: Suggesting MariaDB to change the order for the --prepare, so that these steps are done on the targeted device rather than on the backup location The utility also core dumps if the backup device is write protected. Output from the --prepare test:
|
| Comments |
| Comment by Wayne Marrison [ 2021-01-25 ] |
|
We have exactly the same problem. In order to restore a backup, we need space equivalent to the backup size spare and available in order to do the prepare. This isn't an issue on small databases, but in large installations, the temporary space needed can be several terabytes, which can be expensive to maintain on the rare occasion you need to perform a recovery. |
| Comment by Wayne Marrison [ 2021-02-10 ] |
|
Another thought - would it be possible for the prepare function to happen prior to the data being put in the backup directory? Maybe it could be done on the fly before being written out (to avoid errors in worm filesystems). This would enable a straight copy out of the backup area into the data-dir without any further steps to make the data available to the database. |
| Comment by Sergei Golubchik [ 2021-04-25 ] |
|
I don't quite understand what the problem is. That's right, A backup is intended to be a copy of the database taken at that time, and should be write protected hindering it from being corrupted by malwares, ransomware, bugs etc. But what mariabackup --backup creates is not "a copy of the database taken at that time", it's a mix of data taken at different points in time, to make it a copy of the database taken at particular point in time, one needs to run mariabackup --prepare. After that you have your backup, defined exactly according to your definition and you can store it write-protected as you want (and should, really). Alternatively you can store the result of mariabackup --backup in a write-protected way and copy it somewhere to a writable medium before restoring. The crash is a bug, of course, and should be fixed. |
| Comment by Wayne Marrison [ 2021-04-26 ] |
|
The issue for me is that the capability to "store the result of mariabackup --backup in a write-protected way and copy it somewhere to a writable medium before restoring." is not only time consuming (and therefore in a production environment a key sticking point), but in addition to potentially involve storage teams (to cut & provision the temporary luns), network teams (iscsi?), and the unix teams (mapping the new lun into the o/s) in the provisioning of temporary space turns what should be a seamless 1 team (dba) restore process, into a multi-team, possibly multi-location synchronisation of manpower. You then have the reverse to back out the changes once the database is back into production. I'm talking of multi-terabyte databases here. |
| Comment by Tomas [ 2021-04-26 ] |
|
I agree with Wayne. But according to the manual of mariabackup utility, it mentioning that --prepare should be performed before the users executes the --copy-back If users has to first restore the backup to a write enabled location prior just to execute the --prepare command, than this will be much longer restore time. Know that this works, but not for part restoration. Step 1: stop MariaDB Step 1: stop MariaDB
Step 2: remove data files
Step 3: restore data files
Step 4: Copy additional needed OS files
Step 5: prepare
Step 6: change ownerships of files
Step 7: start MariaDB
|