recovering postgres from a time machine backup

Main menu:

Topics

Recent Posts

Feeds

RSS Feed RSS - Posts

April 2016
M T W T F S S
« Mar   May »
 123
45678910
11121314151617
18192021222324
252627282930  

Past Posts

Java/Java EE

JDBC

Other

recovering postgres from a time machine backup

April 25th, 2016 by Jeanne Boyarsky

Last night, I needed to do a full Time Machine restore on my Mac. I messed up installing things and made the problem far worse in my attempt to “fix” it. Then I tried to rollback a fraction of the disk. The laptop predicted 11 hours to rollback the files. It was easier to rollback to the state a few hours earlier. The only time I did a full Time Machine restore was when I got a new computer. That was going forward in calendar time though. This is the first time I went backwards.

For the most part, it was easy. The Mac prompted me on whether it was ok to erase the disk and restore. That took about two hours. My computer was pretty much set up on restore. It remembered lots down to my internet connection and github key. I got re-prompted from my Dropbox credentials (and for two factor.) No big deal.

Then there was Postgres. Every few seconds, I got the message “Do you want the application “postgres” to accept incoming network connections?” The message only appeared for about a second. Even if I was fast enough to click on it, it was back a few seconds later.

I tried signing the app based on some internet posts. No luck.

Temporary Relief

I got temporarily relief while I looked into the problem by blocking all connections:

  • System Preferences
  • Security & Preferences
  • Click the lock to make changes
  • My password
  • Click unlock
  • Firewall Options
  • Click “Block all incoming connections”
  • Ok

This is not helpful in the long run, but it let me look at things without going crazy.

The problem

I checked the database logs in /Library/PostgreSQL/8.4/datapg_log and found a file every few seconds with:

2016-04-25 20:39:15 EDT LOG:  database system was interrupted; last known up at 2016-04-24 09:18:51 EDT
2016-04-25 20:39:15 EDT LOG:  record with zero length at 0/5C42472C
2016-04-25 20:39:15 EDT LOG:  invalid primary checkpoint record
2016-04-25 20:39:15 EDT LOG:  record with zero length at 0/5C4246E8
2016-04-25 20:39:15 EDT LOG:  invalid secondary checkpoint record
2016-04-25 20:39:15 EDT PANIC:  could not locate a valid checkpoint record
2016-04-25 20:39:15 EDT LOG:  startup process (PID 2326) was terminated by signal 6: Abort trap
2016-04-25 20:39:15 EDT LOG:  aborting startup due to startup process failure

Ah ha! That makes perfect sense. I jumped around in time which would confuse a transaction log. Now,t hat’s something I know how to fix. I did a forced reset of the transaction log:

  1. sudo su postgres
  2. cd /Library/PostgreSQL/8.4/bin
  3. ./pg_resetxlog -f /Library/PostgreSQL/8.4/data

And all better! I turned the firewall connections back to the way they were before I started and good as new.

Write a comment