recovering postgres from a time machine backup

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.

the new two factor authentication for apple

I upgraded the OS on my iPad and MacBook Pro today. I also set up the “new” two factor system. I hadn’t set it up with the old system when I set up two factor on many other accounts.

Setup was easy as described here. I added both my home and cell numbers. I like that you can choose whether to receive a text or phone call with the code. A code was sent to or called on each phone to verify. Since I set this up from my Mac, it became a trusted device. My iPad is recognized as logged in, but not trusted so the code only appears on my Mac.

I then signed in to my apple account in Safari to try to set it up as trusted. On my Mac, the six digit verification code automatically popped up. Minor bug, it was a window that went to the background when I tabbed away and I couldn’t find it when command+tab to switched. I had to drag my browser window out of the way to get it back. When I went to look at iCloud > username > devices on my iPad, I again got the location/verification code pop up on my computer. More convenient this time since it was a different device. I like that it shows the location of the device that wants the code.

I also got an email saying I turned on two factor and that I can opt out by clicking the link for a limited time. I like that the link expires to reduce the attack surface. Of course, I can always opt out through actually logging into my account.

The only problem is that I can’t figure out how to make my iOS 9.1 iPad a trusted device. The option just isn’t there under iCloud > username > password and security.

setting up my new mac from my old mac

My previous Mac turned four years old recently and failed. The Apple store looked at it when it started failing and couldn’t find anything wrong. Then two days later, it died all together. The next step was to send it offsite and hope they could fix it. This would have been the second time my Mac would be out of my possession in the same year. (The first was for an issue with 2011 machines that they fixed for free, but took a week)  I decided to buy a new Mac rather than pay a decent percentage of the cost of a new machine and hope they could fix it. I would have replaced the machine in another year or two anyway so decided to start over clean. I am happy with going back to Mac. I didn’t have a series of small problems like I had on Windows. (Just the big one). I didn’t have to deal with viruses. I had a real UNIX command line.

My choice

I had a 15 inch laptop last time and wanted to stay with that.I chose the higher end of the two 15 inch choices. This is the first time I’ve bought a laptop without adding RAM. (Adding RAM wasn’t an option). The specs:

  • 2.5 GHz quad-core Intel Core i7 processor (Turbo Boost up to 3.7GHz)
  • 512 GB flash storage (I used a little under 256GB on my old machine. I started researching laptops when the machine started showing symptoms so I knew this before it died)
  • 16GB 1600MhZ RAM

Buying the laptop

Since I wasn’t customizing anything, I was able to buy the laptop in the same visit to the store where they confirmed my old laptop was dead. This was in the evening (about 9pm) because I went after being at Maker Faire all day. When I gave the Apple sales rep my credit card, it came back as declined. I’m puzzled because I used it earlier in the day. Luckily the Apple employee wasn’t puzzled. Apparently this happens often. She said multiple credit card companies view a large purchase “late at night” from an electronics store to be suspicious. I called and she was right. The credit card company asked me two security questions. The first I knew. The second was “what is your username for online access to your credit card account.” I have no clue. At the time, that information is in autocomplete on my old computer! (and in a Time Machine backup.) Luckily they asked me a third question. Gotta love security questions that even the authorized person knows the answer to.

Setting up

Time Machine is awesome! All my programs and data automatically showed up. It even remembered which sites I was logged into and what was open when the computer died. I didn’t even have to turn Time Machine back on. It just kept updating from the new computer. I did say that I wasn’t going back to the old computer and not worry about backward compatibility.

I had to reset some of the settings:

  1. Pair trackpad. (I have a wired keyboard).
  2. Cover camera with sticker.
  3. Sign back into Dropbox. I was prompted for my two factor credentials.
  4. Turn off notifications for IM. (I don’t like getting a visual notification) Or more specifically change alert style to “none” for everything. I leave the sound on so I know about it.
  5. Turn on firewall.
  6. Agree to XCode license. I was prompted with “Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo” on my first git pull. I think this was coincidence as there was an XCode update right around the time I changed laptops.
  7. Re-enter product key for Office. (Oddly the Windows 8 in my VM didn’t ask for the product key again)
  8. That’s it. Everything else was remembered.

I just have to label the laptop, but I want to wait one more week for that – until the return period passes.

The missing feature – locks

I have a Kensington combination lock for my laptop. Granted anyone with a power tool (wire cutter or saw) could still steal it. But that takes longer and makes it less likely that a maintenance/delivery person could just swipe it. Apple got rid of the place to plug in the lock. They also got rid of the DVD player, but I don’t use that.

I bought the KTech Bracket which you attach to the laptop and has an adapter to plug the existing lock into. The bracket was easy to attach. The idea is that you unscrew four screws from the laptop and rescrew their longer ones with the product in between. They even give you a screwdriver. I managed to lose one of the screws, but KGear said they will mail me a replacement. I’m not thrilled about the need for a product like this in the first place. Now you just need a screwdriver rather than a wire cutter/saw to disconnect the laptop from the lock. I’m disappointed Apple got rid of this feature from the body of the laptop.