Restoring a specific database conflicts with creating a backup that includes all databases #560
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#560
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 made borgmatic create a backup including all databases by writing "- name: all" in the /etc/borgmatic/config.yaml file.
This is according to the guideline "If you want to dump all databases on a host, use all for the database name".
I have a script that automatically creates new databases. The "- name: all" option comes in handy. Otherwise, I would have to update the config file everytime I create a new database.
Steps to reproduce
Make a backup including all databases with this config:
Run
borgmatic create
Delete the database using
mysql> drop database at409171;
Restore the database using
borgmatic restore --archive blabla-2022-07-05T15:03:38 --database at409171
Actual behavior
After restoring the database, the database is still not there. (
mysql> show databases;
doesn't show the database.)I get this output:
There is no error notification or similar.
Note the line:
Include pattern 'root/.borgmatic/mysql_databases/*/at409171' never matched.
It seems that borgmatic is searching for a file called at409171 (name of the database).
However, when I normally extract the repo, I'll find the dumps of all the databases in one common file called
root/.borgmatic/mysql_databases/localhost/all
.Expected behavior
The database should be restored.
If the database can't be restored (file not found), an error notification should be displayed.
Other notes / implementation ideas
When creating the backup, dump the databases in separate files for each database.
Environment
borgmatic version: 1.6.5
borgmatic installation method: sudo pip install --user --upgrade borgmatic
Borg version: borg 1.1.15
Python version: Python 3.8.10
Database version: mysql Ver 8.0.29-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
operating system and version: Ubuntu 20.04.4 LTS
Thanks for filing this! Yeah, borgmatic restores are currently all-or-nothing when the database is
all
. Your idea for supporting a single database restore with separate files is probably the way to go. See #438 for a similar idea.This part of the ticket is done in master and will be part of the next release. I'm still trying to figure out what to do for the rest of the ticket.
The error notifcation portion of the ticket has been released in borgmatic 1.6.6.
This has been implemented in borgmatic 1.7.6! To enable it, add a
format
option to your "all" database configuration. Then borgmatic will create individual dump files per database. See the documentation for more information: https://torsion.org/borgmatic/docs/how-to/backup-your-databases/#all-databases