Saturday 28 July 2012

Wiki is dead long live Wiki - Restoring Lion Server from TimeMachine




I found myself in the situation of having to restore my company's Lion Server from a Time Machine backup.

All to-do with upgrading to Mountain Lion and finding it completely trashed MySQL, but that's another story




Apple have removed Lion Server install from the App store, but luckily I kept a backup. I created a bootable USB from it and booted the Mac from it. 

From here I was able to restore from a TimeMachine Backup.
Sigh of relief.. We use the Lion Server Wiki extensively and it also is home to a bug tracking database (Mantis), so getting it back up quickly is critical!

Time to sit back and wait..

After the restore the server comes back up and I can login with the original admin password, great! 

Hang on... 



When I access the wiki I get a who series of errors and and no wiki!!! Opening the Server app and selecting the Wiki service, it gives me "error reading settings"

After much googling I found this nugget (here):

sudo su -
sudo echo "limit maxfiles 10240 120000" > /etc/launchd.conf

So I tried, after rebooting I found I could no longer log into the Server app, turned out the service had not started. So i did this:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.servermgrd.plist

This restarted the service and I could start and login to the Server app. Still the Wiki service was showing an error.

Then I found this (here)

sudo ./System/Library/ServerSetup/CommonExtras/PostgreSQLExtras/CoreCollaborationPostgreSQLExtras.sh

That did the job! Something todo with the postgres database for the Wiki.

Now I can get to the Wiki and login..

BUT ..  Where is the data?? 

Our bug database works, but thats using MySql and is separate web site. The Wiki is blank!

Turns out that when restoring from TimeMachine it does not restore the Wiki data

So after much searching I found a solution (here)

Browse to your Time Machine backup and copy your Wiki files to the server. I copied the folder to the users home. The wiki files are in:

/<backupdisk>/Backups.backupdb/<servername>/<date>/<disk>/Library/Server/Wiki/FileData

Copy the FileData folder to the users home

You will also need the postgres database which is in:

/<backup disk>/Backups.backupdb/<servername>/<date>/<disk>/Library/Server/PostgreSQL

I'm not sure why, but mine was in Backup/dumpall.psql.gz So after copying it to the users home I had to extract it.

I did this by changing the permissions using finder to give me read access. Then double clicking on the copied .gz. This gave me a dump all.psql

Then I did the following:

sudo cp -R $HOME/FileData /Library/Server/Wiki/FileData

sudo chown -R _teamsserver:_teamsserver /Library/Server/Wiki/FileData

sudo chmod -R +a "www allow read" /Library/Server/Wiki/FileData

sudo serveradmin stop wiki

sudo serveradmin start postgres

sudo rake -f /usr/share/collabd/server/Rakefile db:drop


sudo createuser -U _postgres -d -s collab


sudo createdb -U collab collab


sudo psql -U _postgres -d collab -U collab -f $HOME/dumpall.psql 


sudo serveradmin start wiki



And that did it, one restored Wiki Server!!


I can't be 100% certain that everything works until people start using it on Monday morning. 

Thanks to all who posted in the forums and blogs! Thanks to Apple for such a nasty bug!

No comments:

Post a Comment