Restore specific schemas #375
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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
At this point using database hooks we can restore whole databases. Problematic is when someone uses multitenancy architucture, so that, one database can hold many separate schemas.
Other notes / implementation ideas
Add to restore optional flag
--schema
taking schema_name to restore. Therefore comamnd:Will destroy and restore only
tenant
schema in databasedb1
and by doing so support multitenancy archituctures.something like this - https://stackoverflow.com/a/1013956/11304203? (for dump files)
I think it's actually easier than that if I'm understanding the ask.
pg_restore
takes a--schema
parameter that restores only objects in the given schema. I don't know of something comparable in MySQL/MongoDB though (which might be just fine).For MongoDB (scehma == collection?), I think it's straightforward too:
https://www.mongodb.com/docs/cloud-manager/tutorial/restore-single-database/#use-mongorestore-to-restore-the-single-database-or-collection
mongorestore
takes a similar--collection
parameter.For MySQL, I didn't find any parameter to restore specific tables yet.
Except some workarounds, like the SO answer I shared above, and dumping just a table to restore it later (can't do for already created dumps, of course).
By the way, if this gets implemented, should there also be a feature to dump a specific schema?
(Ugh, for some reason I'm not getting all projects.torsion.org comment email notifications. Just saw this now.)
Personally, I think it's okay not to support this feature for MySQL/MariaDB (at least not at first) and only support it for databases that do it natively.
That seems reasonable but not required. For dumping, it would probably make sense for it to be a config option in each database's configuration.
@diivi has implemented this via a new
--schema
argument toborgmatic restore
: https://github.com/borgmatic-collective/borgmatic/pull/67It will be part of the next release!
This was just released in borgmatic 1.7.13!