I just switched my mail, web, and database service from NetBSD/i386 2.1 to NetBSD/macppc 3.0_STABLE. Here's how I did it with minimal downtime.

Prepare new server

  • Build and install NetBSD 3.0_STABLE.
  • Build and install pkgsrc packages.

Vet old server

  • With file(1), find binary files with telltale signs of endianness such as “byte-order” and “native” and the like. (Berkeley DB is one such format.) If they're important databases, figure out the commands for dumping and restoring them. For instance, for each user with a trained SpamAssassin:
oldmachine$ sa-learn --backup > spamassassin.txt
newmachine$ sa-learn --restore spamassassin.txt

And for all MySQL databases on the system:

oldmachine# mysqldump -u root -p --all-databases > mysql.txt
newmachine# mysql -u root -p < mysql.txt
newmachine# mysqladmin -u root -p flush-privileges
  • With grep(1), find text files in /home and /etc containing occurrences of the oldmachine hostname. Store a list of the resulting files for later.

Move

  • Leave oldmachine online, in place, and serving normally.
  • Carefully merge /etc from oldmachine to newmachine.
  • On newmachine, temporarily enable root login in sshd(8).
  • Start an initial gigantic rsync(1) of /home, then go do something else for a good long while:
oldmachine# rsync -avz /home newmachine:/
  • When it finishes, do a followup run:
oldmachine# rsync -auvz --delete /home newmachine:/
  • Stop network services and cron on oldmachine. (If you need sshd, open as many shells as you need, then touch /etc/nologin.)
  • Copy /var/cron/tabs to newmachine.
  • On oldmachine, check that mailq is empty or contains nothing of importance to anyone.
  • Dump MySQL, SpamAssassin, and any other important databases.
  • Do another followup rsync run. (This time, the source won't be getting changed while it's being copied).
  • And do it one last time to convince yourself that newmachine really has an identical /home.
  • Unplug the network cable from oldmachine.
  • On newmachine, re-disable root login in sshd.
  • Load MySQL, SpamAssassin, and your other dumped databases.
  • Edit that list of text files and replace oldmachine with newmachine in each.
  • On newmachine, edit /etc/rc.conf to manually configure the same IP address oldmachine had been using, and add an entry for newmachine to /etc/hosts.
  • Reboot newmachine. Wait a few minutes for the nearest router to notice the new MAC address and start sending traffic your way.
  • Watch the system logs for errors until you're convinced nothing has gone horribly wrong.

Beer

  • Technically, this can be done in parallel with earlier steps.

Leisurely finishing touches

  • Send a request to hostmaster to keep the static IP already allocated to you in DHCP, but update the hostname and MAC address associated with it.
  • When that's been done, re-edit /etc/rc.conf to switch to dhclient(8), and remove the temporary entry from /etc/hosts.