a year ago
We have a bunch of database dumps via this tool: https://github.com/railwayapp-templates/postgres-s3-backups
We're trying to figure out how to actually get the restore to work, does anyone have detailed directions?
0 Replies
So the issue we're facing is that we're not sure which pg_restore tool to use. If it's a local postgres installed via homebrew, I'm having a hard time getting timescale and timescale-toolkit installed. Should I be doing this inside of a dockerized postgres/timescale container? Or is there a way to restore directly to a railway instance?
a year ago
what version of postgres are your backups made from?
a year ago
is your backup service running the latest commit?
What do you mean by backup service? We're trying to use pg_restore either on a local machine (postgres installed via homebrew) or via a docker container. In any case, it looks like it needs timescaledb and timescaledb-toolkit installed to restore properly.
a year ago
the backup service that made these backups, just trying to gather information so i can give you the best answer i can
Ah, I see. We made the backups via an instance of https://github.com/railwayapp-templates/postgres-s3-backups with the latest commit. The postgres instance is also really up to date. I ran Railway's migration tool earlier this year to upgrade the postgres version and data store.
a year ago
okay thanks, what is the source image of the database you are trying to restore to?
Honestly, I've tried a whole bunch of options. I've tried another railway postgresql instance which presumably should be the same as the original data source. I've also tried restoring to a homebrew install of postresql@15 and postgresql@16 and a timescaledb docker image (https://hub.docker.com/layers/timescale/timescaledb/latest-pg16/images/sha256-d669a599ce935613c3e322fc56678b76762e53a9f8dac22a86a04c07cb0a4285?context=explore). In all cases, it seems I need both timescaledb and timescaledb-toolkit installed, and none of those destinations have it installed out of the box.
I also tried installing timescaledb and timescaledb-toolkit locally via homebrew, but there's version issues between postgres 15 & 16
a year ago
what is your version of pg_restore?
Depends on which. 🙂 With homebrew 15, it's 15.x and it was giving me an error about incompatible headers. When I installed homebrew's postgresql@16, I think it was pg_restore 16.2, but it might've been different.
The timescaledb docker image has pg_restore 16.2.
a year ago
does your app use anything timescale related?
To my knowledge, not at all. But it seems all of our pg_dumps have the timescale context baked into them.
a year ago
they would, but since you dont need anything timescale related you can ignore any such errors
a year ago
how large are you database backup tarballs?
tbh, I don't even know what timescale is. We use a pretty barebones postgres setup.
a year ago
what command have you ran to restore the backup?
pg_restore -d "postgresql://username:password@localhost:5432/postgres" -F t backup-2024-03-13T06-45-00-104Z.tar
a year ago
are you both pro?
Is that a Railway thing? @cstoneham is the account creator, and I'm pretty sure it's a pro account. I'm his cofounder and an Owner on the account.
a year ago
just asking so i know that you arent trying to restore a 10gb dump to a 5gb database haha
a year ago
look like i have a small backup laying around, ill try some commands to see what works
a year ago
this is what worked for me and my small backup -
un-gzip the tarball to end up with a
backup_filename.tar
filerun
pg_restore --dbname=${DATABASE_URL} --format=tar < backup_filename.tar
wait
a year ago
the backup template makes tar.gz files
a year ago
you where able to restore a what 40gb backup? and theirs is only 10gb
This doesn't actually seem to work through the issues that I'm facing. What version of pg_restore are you using, and are you restoring to another database hosted on Railway?
a year ago
What version of pg_restore are you using
pg_restore (PostgreSQL) 16.0
are you restoring to another database hosted on Railway?
yes
I'm trying this right now. I'm getting pages and pages of this vomit, but maybe it'll work anyway?
pg_restore: error: could not execute query: ERROR: schema "_timescaledb_cache" does not exist
Command was: COPY _timescaledb_cache.cache_inval_bgw_job FROM stdin;
pg_restore: error: could not execute query: ERROR: schema "_timescaledb_cache" does not exist
Command was: COPY _timescaledb_cache.cache_inval_extension FROM stdin;
pg_restore: error: could not execute query: ERROR: schema "_timescaledb_cache" does not exist
Command was: COPY _timescaledb_cache.cache_inval_hypertable FROM stdin;
a year ago
does it stop itself, or have you been stopping it thinking its not doing anything?
I've been trying so many combinations of pg_restore versions and attempts to install timescale that I'm not 100% sure if I've done this test yet.
a year ago
10gb is a big backup, it took several seconds to restore my 108kb backup, i think you should just let it run, whats the worst that can happen?
a year ago
thats very promising
Update here: it took quite a while on my current internet connection, but I was able to successfully restore the backup using your method!
For future readers:
I had to install pg_restore 16.x on my machine (I used homebrew's postgresql@16) and restore to another railway postgresql instance. I was never able to restore to a local db.
a year ago
awesome! maybe next time you need to restore a backup you could temporarily rent a VPS? that's why I would do since I only have 9mbps up
a year ago
just curious what was the final in use size of the volume?
a year ago
that's checks out, glad you where to get this sorted!