How to perform actions after a database hook has completed but before the files gets backed up? #500
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#500
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
I want to perform actions on the mysqldump .sql file generated by the mysql hook.
Since mysqldump (the utility executed by the mysql hook) generates a consolidated single .sql file I want to execute the tool mysqldumpsplitter on the dump file to further fine tune the resulting backup.
The utility offers several ways to operate on a mysql dump, namely I want to split the single .sql into a file for each of its tabale, an action mysqldumpsplitter can peform very easily.
Expected behavior (if a bug)
Thanks for the question! Could you talk a little about your use case? Is it that you want to be able to restore a single table from backups without restoring the whole database? Is so, why? Do you plan to do that via borgmatic or directly with
mysql
via the command-line?Unfortunately, the way that borgmatic dumps from MySQL is to stream the database dump directly from MySQL to Borg. This is for performance and disk use reasons. So there's not (currently) a good place for a third-party tool to hook in. But there might be a way to enhance borgmatic to support your use case if you tell me a little more about it.
The use case I've faced several times is to restore a subset of tables either in the original database or in a new one spun up temporarly for investigation and debugging. Restoring the whole database for such occasions very often takes unnecessary time, load and disk space.
I strongly believe (and it's also very often reccomanded) that it's better to restore a whole datatabse at a given point in time (optionally re-running binlogs in the case of MySQL) since there is no practical way to know the exact state of the database when a crash\issue happened. Restoring a subset of tables should be a manual approach only for very specific scenarios to avoid breaking relationships between tables and the like. I don't think an automatic borgmatic pathway fits here.
So the behaviour of restoring a subset of tables I expect it to be a manual pathway where one either extract or mount a repository and like a surgeon restore what's deemed necessary. Having a backup already populated with a single .sql dump file plus the single tables would enhance and streamline such flow.
While replying I also thought of a question, how does borgmatic behave when a mysqldump is run with the --tab option? The dump contains schema and data split in different files, does borgmatic also perform a
LOAD DATA
statement on behalf of the user?Closing lines
Given the sporadic need and niche use case I suppose we are better off extracting\mounting an archive whith the full database dump and manually run the mysqldump splitter tool.
I wasn't aware of this option, but my guess is that at least currently, it wouldn't work. That's because borgmatic expects
mysqldump
to stream a single dump file to standard output. However, you are welcome to try this option as an experiment, selecting a destination directory that you've configured to be backed up as part of borgmatic'ssource_directories
. That would probably mean you couldn't restore those tab-separate files withborgmatic restore
, but you might be able to restore them manually.Sounds good. I'll close this for now, but feel free to add any other thoughts/feedback here.