User Tools

Site Tools


Bare Metal Restore

The following are the instructions for performing a full bare metal recovery of a FreeBSD client. I modified the instructions found in the official Bacula documentation. Alex Torres provided the original documentation with additions made by Jesse Guardiani and Dan Langille.

1. Boot with the FreeBSD installation disk.

2. If you need to create partitions, Go to Custom, Partition and create your slices and go to Label and create the partitions that you want. Apply changes. If you do not need to create partitions, skip to next step.

3. Go to Fixit to start an emergency console.

4. Set new disk as root

  # mkdir /mnt/disk          # this is the root of the new disk 

5. Mount partitions the same way as the old system partition configuration

  # mount /dev/ad0s1a /mnt/disk 
  # mount /dev/ad0s1d /mnt/disk/var 
  # mount /dev/ad0s1e /mnt/disk/tmp 
  # mount /dev/ad0s1f /mnt/disk/usr 
  # ..... 

Note: under OS version 4 or lower, your disk devices may be in /mnt2/dev not /dev.

6. If partitions are there but you still want to restore from a complete backup and old data exists on all partitions, do this:

  # cd /mnt/disk 
  # chflags -R noschg * 
  # rm -rf *

7. Set up network configuration:

  # ifconfig rl0 192.168.x.x/x 
  # route add default 192.168.x.x

8. Switch to new temp directory

  # cd /mnt/disk/tmp

9. Copy Bacula FD files & libraries to this path

  # ln -s /mnt2/usr/bin /usr/bin 
  # needed in order to use sftp 
  # sftp 192.168.x.x

get static-bacula-fd, bacula-fd.conf,,, and libc.so7.

10. Set executable bit on static Bacula FD

  # chmod u+x static-bacula-fd

11. Modify bacula-fd.conf to fit this machine if needed- i.e. client name and password.

12. Copy libraries to where chroot expects to find them:

  # cp /mnt2/libexec/ /mnt/disk/libexec/ 
  # cp /mnt/disk/tmp/ /mnt/disk/usr/local/lib/ 
  # cp /mnt/disk/tmp/ /mnt/disk/usr/local/lib/ 
  # cp /mnt/disk/tmp/ /mnt/disk/lib/ 
  # ldconfig -m /tmp

Note: ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, and in the trusted directories (/lib and /usr/lib).

13. Create /proc

  # mkdir /proc

14. Copy sh which is needed in order to run chroot in /mnt/disk

  # cp /bin/sh /mnt/disk/    # necessary for chroot

15. Put your bacula-dir's IP address and domain name in /mnt/disk/etc/hosts if it's not on a public network. Otherwise the FD on the machine you are restoring to won't be able to contact the SD and DIR on the remote machine. Or put IP addr in /etc/hosts. hosts file should contain as follows:


16. If these directories do not exist, do:

  # mkdir -p /mnt/disk/var/db/bacula 
  # mkdir -p /mnt/disk/var/run

17. Start bacula-fd

  # chroot /mnt/disk /tmp/static-bacula-fd -c /tmp/bacula-fd.conf

May not succeed due to missing ELF library or other libraries. If missing libraries, do:

  # ldd static-bacula-fd

to identify missing libraries.

Sometimes chroot may not work. In that case, you can try:

  # mnt/disk/tmp/static-bacula-fd -c /mnt/disk/tmp/bacula-fd.conf

18. Now you can go to bacula-dir and restore the job with the entire contents of the broken server. Be sure to restore to / if chroot function (step #17) succeeds. If chroot fails to execute but the alternate command does, be sure to specify /mnt/disk as the restore point instead of /tmp/bacula-restores or even /.

Doug Sampson 2009/03/10 13:50

freebsd_bare_metal_recovery_-_client.txt · Last modified: 2009/03/10 17:57 (external edit)