# Create Image of Server



## nick22_3 (Mar 14, 2018)

Hi,

First, I will preface this with; I am not very familiar with FreeBSD. One of the hard drives has failed in our server, which is getting older and needs to be replaced. It is hosting a website using apache and has software/data that uses mysql, and is very crucial to the business. I am not sure how it is installed, or what is all needed to just set it up/configure a new server.

I am wondering if there is a way to take an image of the current FreeBSD OS on the server (while it is running), and restore it to a new server so I don't have to worry about reinstalling software and trying to get it configured correctly.

Thanks!


----------



## chrbr (Mar 14, 2018)

Please have a look at http://www.wonkity.com/~wblock/docs/html/backup.html. And take the opportunity to check the other pages, too. It is a great collection.


----------



## SirDice (Mar 14, 2018)

Make sure you also have proper backups (mysqldump(1)) of the MySQL databases. Just in case the machine decides to die before you have the new system up and running. I'm actually hoping you already have those but it's always a good idea to check and verify.


----------



## obsigna (Mar 14, 2018)

nick22_3 said:


> ... I am wondering if there is a way to take an image of the current FreeBSD OS on the server (while it is running), and restore it to a new server so I don't have to worry about reinstalling software and trying to get it configured correctly.



It is possible, while your requirement of doing it "_while it is running_" limits the number of possibilities, and I doubt that the dump(8)/restore(8) combo would be the best choice, especially in cases when there may be already some read failures on the old disk. The most fail safe option would be file system cloning.

In case we are talking about UFS formatted volumes, then you would prepare the new disk using gpart(8) and newfs(8), and then you would use sysutils/clone or net/rsync to create an exact copy of the whole file system on the new disk. For this you would need to connect the new disk to the old server either on a free SATA bus or by the way of a USB enclosure you may plug it into a USB port. Please note, that FreeBSD got still some problems with USB3. And if your old server is pre-11, then you don't want to even try it.

In case we are talking about ZFS, then you need to ask the ZFS experts for the proper way of cloning a ZFS disk.

In any case you would need to adjust the copy of /etc/fstab for the device names (or labels) of the new disk. And as SirDice mentioned, it would be best to run a final mysqldump(1) right before you take the old server offline. So you would be able to restore the final state on the new server.


----------



## SirDice (Mar 14, 2018)

Oh, and as this system is considered "crucial", don't settle on a single replacement server. Replace it with two servers and configure a proper HA solution. Even that brand new server can develop hardware errors and you also need to take it offlline regularly in order to update it.

If your boss starts moaning about costs ask him what it would cost his business if that brand new server caught fire and burned to a crisp.


----------



## PacketMan (Mar 29, 2018)

SirDice said:


> If your boss starts moaning about costs ask him what it would cost his business if that brand new server caught fire and burned to a crisp.



I use the same question with customers when designing them a shiny new large Juniper or Cisco network.  That usually works with smart people.


----------



## gkontos (Mar 29, 2018)

I have not tried it with FreeBSD but it works fine with Linux. So, in case virtualisation is an option for you --> http://libguestfs.org/virt-p2v.1.html


----------

