timescaledb-backup
timescaledb-backup copied to clipboard
Add support for schema-only dump/restore
In order to do a schema only dump/restore we need to a) do a schema only dump of everything b) do a dump of the timescale catalog which we'll need to restore
schema only restores can happen either from a schema only dump or not, but they need to restore the catalog schema as well.
In doing some testing with pg_dump, I think you can exclude the entire _timescaledb_* schema pattern, since these are re-created when the extension gets installed. The tables, then, are re-created. But they need select create_hypertable re-run on them. This would reduce what gets stored, since we wouldn't need to store and restore all the individual chunk schemas.
This also doesn't migrate caggs, jobs, etc. So these would all need to be extracted by the tool and re-created as well. This is hard to do with just pg_dump and pg_restore, though.
It's very likely this might require more than just calling pg_dump / pg_restore, though, so perhaps there's a more surgical way to dump/restore the catalog data in a way that leaves you with ready, but empty hypertables without also having a bunch of empty chunks pre-created.
There's also a good way of doing this that would eliminate all the current chunks of a table by excluding all the tables in the chunk catalog and then doing a schema only dump and then dumping/restoring the catalogs other than the chunk, this would mean that you get an "empty" hypertable and would limit the amount of locking etc on restore which can still take a long time if you're not careful.