[MDEV-18762] Support easy restore of partial backup Created: 2019-02-27 Updated: 2023-12-26 Resolved: 2023-12-11 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | mariabackup, Storage Engine - InnoDB |
| Fix Version/s: | 11.2.1 |
| Type: | New Feature | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Yuchen Pei |
| Resolution: | Fixed | Votes: | 13 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
This came up in an InnoDB Birds of a Feather session. mariabackup --export is internally executing FLUSH TABLES…EXPORT on the backed-up files to allow the files to be imported to another server instance. But it does not appear to generate a script file that could be conveniently executed by the user in order to import the tables. It would be nice to have a sequence of SQL statements and shell commands for importing the exported tables. Maybe we could generate several files:
|
| Comments |
| Comment by Marko Mäkelä [ 2019-02-27 ] | ||||||||||||||||||||||||||||||
|
As part of this, we should also handle tables that use the DATA DIRECTORY attribute. Based on a discussion with the same user, I was wondering if there is a bug that we refuse IMPORT TABLESPACE if you import a table whose DATA DIRECTORY attribute in the .cfg file disagrees with the current table definition, but it appears to be OK in 10.2:
The only surprise here is that the .cfg file must be located in the directory specified by DATA DIRECTORY, plus the name corresponding to the schema name (USE test was implied in this case). | ||||||||||||||||||||||||||||||
| Comment by Chris Calender (Inactive) [ 2019-03-13 ] | ||||||||||||||||||||||||||||||
|
I would like to suggest that we create the "create.sql" file whether it is a "partial" or "full" backup. Oftentimes, folks have a full backup too, where they only need 1 schema or even one table. It is a lot of extra work to restore the full backup, then dump/extract what they need, then re-restore just those table(s). | ||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2019-03-15 ] | ||||||||||||||||||||||||||||||
|
ccalender The thing with full backup is that the "export" step does not run, thus create.sql is not that useful, as one still needs to start the database and do the "export" | ||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-03-15 ] | ||||||||||||||||||||||||||||||
|
wlad, I think ccalender is probably thinking about the cases where users want to do a partial restore when they are starting with a full backup, rather than a partial backup. But I don't think this is an issue at all because Mariabackup's --export option doesn't care whether the backup being prepared is a full backup or a partial backup, so I think this should already work. I believe the --export option should already work with full backups too. It should even be safe to use with backups that have already been prepared, since Mariabackup zeroes out the redo log during the prepare process. e.g. take a full backup:
prepare it:
and then try --prepare --export:
We can see that the .cfg files were exported, even for the full backup:
| ||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2019-03-20 ] | ||||||||||||||||||||||||||||||
|
I think that instead of generating shell scripts and batch files, it is better to have an extra option for copy-back , e.g --copy-back --import , which restores the tables that were backed up with The create.sql and import. sql files will still be generated, in case someone wants to manually one or several tables from backup. | ||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-09-09 ] | ||||||||||||||||||||||||||||||
|
Is "In Progress" still the correct status for this task? Is this task actively being worked on? | ||||||||||||||||||||||||||||||
| Comment by Hartmut Holzgraefe [ 2020-01-15 ] | ||||||||||||||||||||||||||||||
|
The generated SQL CREATE script should also take care to set things like mysql56_temporal_format correctly before doing the actual CREATE, as this option has an effect on how SQL column types like DATETIME are represented internally in InnoDB. See also | ||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-01-22 ] | ||||||||||||||||||||||||||||||
|
We have several bugs that affect IMPORT TABLESPACE: | ||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-05-30 ] | ||||||||||||||||||||||||||||||
|
I think that implementing | ||||||||||||||||||||||||||||||
| Comment by Hartmut Holzgraefe [ 2023-07-12 ] | ||||||||||||||||||||||||||||||
|
So with We had yet another customer ask about "Need STEPS to restore single database from mariabackup" just today. So nine related support cases, of which five are still active, and I'm pretty sure that there are more that are not even linked to this MDEV yet, esp. from pre-2019 ... | ||||||||||||||||||||||||||||||
| Comment by Hartmut Holzgraefe [ 2023-12-11 ] | ||||||||||||||||||||||||||||||
|
With With that restoring a single database, or a specific subset of tables, now has become as easy as "just copy the related table files from a backup directory prepared with "--export" option, and ALTER...IMPORT them into the desired target datbase(s). With that we can probably also close this one as "fixed in 11.2.1", too, same as | ||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-12-11 ] | ||||||||||||||||||||||||||||||
|
okay, thanks. I'm tentatively closing it then. Can be reopened, if people will think that |