timescaledb-backup icon indicating copy to clipboard operation
timescaledb-backup copied to clipboard

Add support for schema-only dump/restore

Open davidkohn88 opened this issue 5 years ago • 2 comments
trafficstars

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.

davidkohn88 avatar May 21 '20 12:05 davidkohn88

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.

tylerfontaine avatar Jan 14 '21 22:01 tylerfontaine

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.

davidkohn88 avatar Feb 03 '21 20:02 davidkohn88