Skip to main content
RunBook Academy

OPNsenseXL · Backup, Restore, Disaster RecoveryRestore from backup

Restore from backup — the procedure, the verification, and the rollback plan

Intermediate⏱ ~16 minconfigctlsshxmllintpfctl

What you'll learn

  • Apply the three restore methods (GUI, API, single-user shell) and select the right one for the situation
  • Execute the post-restore verification checklist
  • Perform a partial restore of a single section without overwriting the running configuration
  • Plan the rollback when a restore itself causes the next incident

Prerequisites

Verified against OPNsense 25.x · FreeBSD 14.x · PF (FreeBSD packet filter) FreeBSD 14.x · Unbound 1.20+ · Kea DHCP OPNsense 25.x plugin · WireGuard in-kernel + OPNsense plugin · strongSwan (IPsec plugin) OPNsense 25.x plugin · OpenVPN 2.6.x · Suricata 7.x · 2026-08-14

Not yet marked complete on this device.

A backup is only useful if it can be restored. The restore procedure looks simple from the GUI: select the snapshot, click Restore, reboot. The interesting parts are everything that happens after the firewall comes back up — the verification, the partial-restore techniques for fixing one section without overwriting the rest, and the rollback plan when the restore itself causes the next incident.

This lesson covers the three restore methods, the post-restore verification checklist, the partial-restore discipline, and the rollback plan that makes the restore itself safe.

The three restore methods

OPNsense supports three ways to apply a configuration backup. They are not interchangeable.

MethodWhen to usePre-conditions
GUI: System → Configuration → Backups → RestoreThe GUI is reachable, the operator is hands-on, the backup file is on the workstationGUI access, valid credentials
API: POST /api/core/backup/restoreThe restore is automated (configuration management), or the GUI is reachable but the operator prefers the APIAPI access, valid API key
Single-user shell: cp backup /conf/config.xml && rebootThe GUI is unreachable, the console is the only path, or the operator needs to restore before rebootConsole access (physical or virtual)

The GUI method is the most common. The operator uploads the file, confirms the warning dialog, and the firewall reboots with the restored configuration. The API method does the same thing programmatically. The shell method is the last resort: when the GUI is unreachable but the operator has console access, the operator copies the file into place from the console and reboots.

The post-restore verification checklist

A firewall that has just booted from a restore is in an unknown state. The boot succeeded; the services may not all be running; the rules may have been regenerated; the interfaces may have re-assigned; the certificates may have moved. The operator runs the verification checklist before declaring the restore successful.

CheckCommandExpected
Interfaces upifconfigAll configured interfaces present and up
Routing tablenetstat -rnDefault route present, expected routes present
Firewall rulespfctl -s rulesExpected count of rules, expected anchor blocks
NAT rulespfctl -s natExpected outbound NAT, port-forwards present
DNS resolverdrill @127.0.0.1 example.netResolves (or returns NXDOMAIN for non-existent)
DHCP serverservice dhcpd statusRunning on expected interfaces
IPsec tunnelsipsec statusallTunnels either established or in expected state
WireGuard tunnelswg showInterfaces present, peers configured
GUI reachableBrowserLogin page loads, cert is the expected one
SSH reachablessh root@<fw>Banner matches expected
NTP synchronisedntpq -pReachability 377 on at least one source
Logs flowingtail /var/log/system/latest.logRecent entries, no error spam
Read-only / SafePost-restore sanity check
$ pfctl -s rules | wc -l && pfctl -s nat | wc -l && ifconfig | grep -c "UP"
142
28
6

Illustrative output

The checklist is not optional. The operator who skips the verification and announces “the firewall is restored” without confirming each item is the operator whose next page is the next incident. The verification is the proof that the restore produced the configuration the operator intended, not just a configuration.

Partial restore: fixing one section without overwriting the rest

Sometimes the operator does not want a full restore. The change that broke things was a single rule, a single alias, a single certificate — and the rest of the configuration is correct. A full restore loses every change made since the backup. A partial restore replaces the broken section with the version from the backup and leaves the rest alone.

The technique:

  1. Download the backup. Copy the XML to a workstation.
  2. Identify the section to restore. Open the live XML (download a current snapshot) and the backup XML. Diff them with xmllint --c14n and diff.
  3. Extract the section from the backup. For example, the \<filter\> section, the \<aliases\> section, or a single \<alias\> element.
  4. Replace the section in the live XML. Use xmllint to validate the merged XML before applying.
  5. Apply via API or paste into the GUI. The API allows a single \<section\> patch; the GUI does not, so the operator must use the API for partial patches.

The partial restore is harder than the full restore. The operator must understand the XML structure, must validate the merge, and must know which sections can be patched independently. The XML sections that are safe to patch in isolation: \<aliases\>, \<filter\> (with caveats — NAT rules live elsewhere), \<staticroutes\>, \<cron\>, \<ntpd\>. The sections that must be patched together: \<IPsec\> and \<IPsec\>\<phase1\> together, \<wireguard\> and \<wireguard\>\<peer\> together.

The rollback plan when the restore itself breaks things

The restore can fail. The backup file can be from a different firmware version, the XML can reference a plugin that has been removed, or the restored configuration can conflict with the running services in ways that did not exist when the backup was taken. The operator needs a rollback plan that is exercised before the restore, not after.

The rollback plan:

  1. Pre-restore snapshot of the current configuration. Even if the current configuration is broken. The broken configuration is the rollback target if the restored configuration is also broken.
  2. Document the baseline. Record the count of rules, NAT entries, interfaces, and the version of the firmware. The baseline is the comparison for the verification checklist.
  3. Test the restore on isolated hardware. If the production restore is high-risk, restore the same backup to a test appliance first. Confirm the boot, the verification checklist, and the next-boot behaviour.
  4. Plan the next restore. If this restore is wrong, what is the next backup to try? The previous one? The one before that? The names of the candidate backups must be in the change ticket before the restore begins.

Summary

  • Three restore methods: GUI, API, single-user shell. Pick by access path.
  • The verification checklist runs after every restore. No exceptions.
  • Partial restores are possible but require XML fluency and validation.
  • A pre-restore snapshot is the rollback path if the restore fails.
  • Test the restore on isolated hardware before applying to production.

Knowledge check · 4 questions

  1. Q1. You are about to apply a configuration restore via the GUI. The GUI is reachable, the credentials are correct, and the backup file is on your workstation. What is the single most important pre-restore action?

  2. Q2. A partial configuration restore via the OPNsense API can safely patch the IPsec phase-1 section without touching the phase-2 sections.

  3. Q3. Which of the following must be in the post-restore verification checklist? Select all that apply.

  4. Q4. Your restore applied cleanly, the GUI is reachable, and the routing table is correct. The verification checklist still requires you to inspect the logs and the NTP state. Why?

Passing score: 75%. Answers are checked in this browser.