Restore pfsense configuration backup from console using USB drive


In this tutorial you will learn:
  • How to identify USB drive on pfsense system
  • How to mount USB drive/stick
  • How to restore pfsense backup
pfsense the FreeBSD firewall system
pfsense the FreeBSD firewall system

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System pfsense FreeBSD firewall
Software N/A
Other Privileged access to your pfsense system, configuration backup file and USB drive/stick
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Restore pfsense configuration backup from console using USB drive step by step instructions

In this article we assume that you already have USB drive/stick formatted as FAT32:
Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1        2048 30523391 30521344 14.6G  b W95 FAT32
and that you have already placed the pfsense configuration backup file on the USB drive. Example:
$ ls
config-FIREWALL.localdomain-20190906160320.xml
 
    1. Mount USB drive on pfsense system.
      Insert the USB drive into the pfsense system’s USB slot. Once ready, access pfsense shell ( option 8) Shell ) either by directly log in into your pfsense console or via remote SSH connection. Next, use camcontrol wiith devlist argiment to locate your USB drive. Example:
      # camcontrol devlist
      <SanDisk SSD U100 16GB 10.56.00>   at scbus0 target 0 lun 0 (ada0,pass0)
      <PLDS DVD-RW DH16AFSH DL31>        at scbus1 target 0 lun 0 (cd0,pass1)
      <Generic STORAGE DEVICE 9843>      at scbus2 target 0 lun 0 (da0,pass2)
      <Sony Storage Media 0100>          at scbus3 target 0 lun 0 (pass3,da1)
      
    2. In the case above our USB disk storage device can be accesses vile 
da1
    1.  block device name. Next, execute the 
ls command
    1.  to list all available partitions:
% ls /dev/da1*
/dev/da1   /dev/da1s
    1. In this case our USB drive has only a single partition which can be accessed via 
/dev/da1s
    1.  block device name. This is also the partition where the actual pfsense configuration backup file is stored.


    1. Mount USB drive
      Use the mount_msdosfs command to mount your USB drive into the /media/usb directory:
      # mount_msdosfs /dev/da1s1 /media/usb
      
      Confirm that the USB drive is now mounted and you can access the pfsense configuration backup file:
      % ls /media/usb
      config-FIREWALL.localdomain-20190906160320.xml
      
      Mount USB drive on the pfsense FreeBSD system
      Mount USB drive on the pfsense FreeBSD system


  1. Set configuration backup restore
    Overwrite the existing configuration file with the backup configuration file on your USB drive. Your configuration backup file name will be different hence adjust the below command accordingly:
    # cp /media/usb/config-FIREWALL.localdomain-20190906160320.xml /cf/conf/config.xml
    
    and remove the existing configuration cache file:
    # rm /tmp/config.cache
    
  2. Reboot the pfsense system
    Almost done. All what remains is to reboot the pfsense system to trigger the backup restore and boot to a new configuration.