Restore specific schemas #375

Closed
opened 2020-12-04 09:26:33 +00:00 by pbakiewicz · 6 comments

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:

borgmatic restore --schema tenant1 --database db1

Will destroy and restore only tenant schema in database db1 and by doing so support multitenancy archituctures.

#### 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: ``` borgmatic restore --schema tenant1 --database db1 ``` Will destroy and restore only `tenant` schema in database `db1` and by doing so support multitenancy archituctures.
witten added the
good first issue
label 2023-02-04 21:25:10 +00:00
Collaborator

something like this - https://stackoverflow.com/a/1013956/11304203? (for dump files)

something like this - https://stackoverflow.com/a/1013956/11304203? (for dump files)
Owner

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).

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).
Collaborator

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?

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?
Owner

(Ugh, for some reason I'm not getting all projects.torsion.org comment email notifications. Just saw this now.)

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).

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.

By the way, if this gets implemented, should there also be a feature to dump a specific schema?

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.

(Ugh, for some reason I'm not getting all projects.torsion.org comment email notifications. Just saw this now.) > 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). 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. > By the way, if this gets implemented, should there also be a feature to dump a specific schema? 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.
Owner

@diivi has implemented this via a new --schema argument to borgmatic restore: https://github.com/borgmatic-collective/borgmatic/pull/67

It will be part of the next release!

@diivi has implemented this via a new `--schema` argument to `borgmatic restore`: https://github.com/borgmatic-collective/borgmatic/pull/67 It will be part of the next release!
Owner

This was just released in borgmatic 1.7.13!

This was just released in borgmatic 1.7.13!
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#375
No description provided.