Postgresql – Rsync’ed postgres databases won’t allow log-on, gets “cache lookup failed for relation” error

backuppostgresql

Running postgres 9.4.4 on a SLES11 SP4 Machine.

I'm rsyncing an entire machine over the Internet to create a copy of the operating system and when I try running postgres (the service starts). I stoped the postgresql service before running rsync.

Logging in to my database (that works on the machine I rsynced from), I get

$ psql -U [my_username] [my_database]

psql: FATAL: cache lookup failed for relation 1259

Searching here and there shows me lots of info for this error, but most of them appear to be for people who can actually log in to their database.

I can log in as the postgres user, but I don't think that user can fix it.

I've tried rsyncing again, in case something was lost in translation, and got exactly the same error. So something must be gummed up. I've rebooted, restarted postgresql. Ran vacuum (as postgres, probably doesn't touch the busted relation).

I'll probably have to go hack on the config files to give the postgres user access to the tables, but short of that, are there any ways I can fix this. I really only need the schema to survive the rsync, the data can (and will) get blown away and repopulated by another machine.

Best Answer

Make sure that postgres is killed on the side you are rsyncing from as well as the side you rsynced to (you goofus).

Smart Peter: After you ran rsync what files did it copy?

Goofus Peter: Um almost everything, except the network stuff, I needed that

Smart Peter: so, everything like all the pid's and cron and everything

Goofus Peter: I guess so, but postgres was off on the machine I was copying from

Smart Peter: Well, was postgres on on the machine you were copying too?

Goofus Peter: Oh crap

... Later ...

Goofus Peter: Hey, it still didn't work, and now I can't even start postgres!

Smart Peter: Is it running

Goofus Peter: How could it be running if I couldn't even start it?

Smart Peter: Because it was running all along!

Goofus Peter: (gets cut off)

Smart Peter: Because you have a cron job that restarts it

Goofus Peter: But I killed cron

Smart Peter: Did you kill it, or did you stop the service

Goofus Peter: Stopped the service...

Smart Peter: So basically, you left the bodies and moved the headstones?

Goofus Peter: OK I'll make sure everything is dead and call you back

... Time passes ...

Goofus Peter: OK everything worked

Smart Peter: Great, I'll go tell stackexchange!