Migrate FOG
Contents
Overview
This article explains how to move FOG Settings & images from an old box to a new box. This is more safe and sure than attempting an OS upgrade, which is risky and might leave you with a broken server. It's more safe and more sure because we know exactly what to move over and how to do it. An OS upgrade is risky because if you upgrade and it doesn't work or leaves fog in an unusable state, we have no idea what broke or how to fix it without days of exhaustive troubleshooting that may or may not lead to a solution. Migrating from an old box to a new box also leaves your old box intact, which is another safety net in this method.
Step 1 - Building the new server
The first step in this process is building a new FOG server using the latest version of your chosen Linux distribution. I would recommend CentOS or Debian. Go through the normal steps of setting up the OS. do not create a user called fog - it will cause you nothing but pain later on. If you're installing Debian or Ubuntu, name the user "tech" or "Administrator" or whatever your first name is, like "Bob". If you're using CentOS or Fedora or RHEL, no extra user is necessary, just set a good root password. Name the server fog-server if possible, and set a static IP or create a DHCP reservation for the server. After an IP is set, use your DNS server and create an 'A' record for the server's name and IP, Google search DNS A record if you're unsure how to do that. To install FOG, follow an appropriate installation manual or the Upgrade to trunk article.
Step 2 - Migrating images & database
The entire point of migrating is usually saving your host registrations, group configurations, image assignments, and your images. There is a great number of ways to do these this, but for inexperienced or beginner Linux users I would recommend leveraging NFS on the new FOG Server.
Related articles:
Using NFS
Because the new FOG Server provides an NFS share, this is the easiest approach. This method is also uniform across the different distributions. This approach also works whether the old FOG Server's web interface is functional or not.
Mounting
Via Terminal or SSH on the old FOG server, mount the new fog server's /images/dev directory to a local directory on the old server called /new. Where x.x.x.x is the new fog server's IP address.
mkdir /new mount /new x.x.x.x:/images/dev
Export DB
We will export the database and move the export to the new server. This is performed on the old FOG Server. There are a few different examples of how to do this below, depending on if you're using a password or not, and how MySQL is configured. One of them will work for you.
#No password. mysqldump -D fog > /new/fogdb.sql #Password with root user. mysqldump -D fog -u root -p > /new/fogdb.sql #No password, localhost. mysqldump -D fog -h localhost > /new/fogdb.sql #No password, local loopback. mysqldump -D fog -h 127.0.0.1 > /new/fogdb.sql #Password with localhost. mysqldump -D fog -h localhost -u root -p > /new/fogdb.sql #Password with local loopback. mysqldump -D fog -h 127.0.0.1 -u root -p > /new/fogdb.sql
Export Images
Now to move over the images. Again, this is performed on the old FOG server. The more images you have, the longer the below command will take to execute.
copy -r /images/* /new
Importing DB
Via Terminal or SSH on the new FOG server, we now need to import the database. Assuming you followed the above steps for exporting exactly, one of the below methods will work for you.
#No password. mysql -D fog < /images/dev/fogdb.sql #Password with root user. mysql -D fog -u root -p < /images/dev/fogdb.sql #No password, localhost. mysql -D fog -h localhost < /images/dev/fogdb.sql #No password, local loopback. mysql -D fog -h 127.0.0.1 < /images/dev/fogdb.sql #Password with localhost. mysql -D fog -h localhost -u root -p < /images/dev/fogdb.sql #Password with local loopback. mysql -D fog -h 127.0.0.1 -u root -p < /images/dev/fogdb.sql
After the database is successfully imported, you should delete the old file or move it. This is done on the new server. Here's the command to delete it:
rm -f /images/dev/fogdb.sql
It's important to note that this step will make the new server's web interface credentials the same as whatever the old server's was. If you don't know what the password is, you can follow steps here to reset the default web interface password: Password_Central#Web_Interface
Arranging Images
This step is performed on the new FOG server. In this step we're simply moving the images to where they are supposed to be and setting the correct permissions. This step assumes that your new server's images directory is in the default location and you followed the above steps for moving them over exactly.
rm -f /images/dev/.mntcheck mv /images/dev/* /images touch /images/dev/.mntcheck chown -R fog:root /images chmod -R 777 /images
Step 3 - Only if old server was FOG 1.3.0+
Because of the security model of FOG 1.3.0+ and the new FOG Client, without the proper CA and ssl certificates present on the new fog server, any currently deployed hosts with the new FOG Client installed will ignore the new server and not accept commands from it. This is by design.
In order to maintain control of existing hosts that have existing new FOG Clients installed or existing images that have the new FOG Client built into them, you must copy this directory from the old server to the new server: /opt/fog/snapins/ssl
Using NFS
If you followed the NFS instructions in Step 2 and have not shutdown or rebooted your old fog server since then, you can use the mount that should still be there. The below steps are performed on the old FOG server.
cp -R /opt/fog/snapins/ssl /new
On the new FOG Server, delete the existing ssl directory and then move the old ssl directory to the proper location, and then set permissions.
rm -rf /opt/fog/snapins/ssl mv /images/dev/ssl /opt/fog/snapins #Fedora, CentOS, and RHEL users should use this command to set permissions: chown -R fog:apache /opt/fog/snapins/ssl #Debian, Ubuntu, and Ubuntu variant users should use this command to set permissions: chown -R fog:www-data /opt/fog/snapins/ssl
To complete the ssl migration, on the new FOG Server, re-run the fog installer that you used in Step 1.
Step 4 - Fix IP Address & Passwords on new server
Related articles:
Related tool: https://github.com/FOGProject/fog-community-scripts/tree/master/updateIP
Because we have imported the old database into the new server in order to preserve all of the host data, image definitions, group definitions, image assignments, and so on, we also imported all of the old server's IP Addresses and passwords along with it. This can't be helped using the approach we took - which is the approach to take if your web interface on the old server was just completely not working. Because of this, we need to change just a few places in the FOG Web GUI, and change the old FOG Server's IP address to the new FOG Server's IP Address, and update a few passwords.
First, we must find out what the new FOG Password is. On the new FOG Server, run this command and note the line that begins password=
cat /opt/fog/.fogsettings
You'll want to copy/paste the password because of it's length.
Paste the password into the below fields in the new FOG Server's web interface:
- Web Interface -> Storage Management -> [click node name] -> Password
- Web Interface -> FOG Configuration -> FOG Settings -> TFTP Server -> FOG_TFTP_FTP_PASSWORD
Update the IP Address in the below fields in the new FOG Server's web interface:
- Web Interface -> Storage Management -> [click node name] -> Password
- Web Interface -> FOG Configuration -> FOG Settings -> Web Server -> FOG_WEB_HOST
- Web Interface -> FOG Configuration -> FOG Settings -> TFTP Server -> FOG_TFTP_HOST