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 theoldmachine
hostname. Store a list of the resulting files for later.
Move
- Leave
oldmachine
online, in place, and serving normally. - Carefully merge
/etc
fromoldmachine
tonewmachine
. - On
newmachine
, temporarily enable root login insshd(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
onoldmachine
. (If you needsshd
, open as many shells as you need, thentouch /etc/nologin
.) - Copy
/var/cron/tabs
tonewmachine
. - On
oldmachine
, check thatmailq
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 insshd
. - Load MySQL, SpamAssassin, and your other dumped databases.
- Edit that list of text files and replace
oldmachine
withnewmachine
in each. - On
newmachine
, edit/etc/rc.conf
to manually configure the same IP addressoldmachine
had been using, and add an entry fornewmachine
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 todhclient(8)
, and remove the temporary entry from/etc/hosts
.