Skip to content

Commit 4c72bbd

Browse files
authored
troubleshooting: Add section for restoring config.xml from backup cache via serial console (#698)
1 parent ed4048d commit 4c72bbd

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

source/troubleshooting.rst

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ be found in the list below.
7272
:glob:
7373

7474
troubleshooting/password_reset
75+
troubleshooting/config_reset
7576
troubleshooting/webgui
7677
troubleshooting/boot
7778
troubleshooting/hardening
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
====================================
2+
Restore Configuration via Console
3+
====================================
4+
5+
Sometimes you may accidentally introduce a breaking change that interrupts network access, prevents user login or makes SSH and WebGUI inaccessible.
6+
Rolling back without a reinstall is possible if there is serial and console access.
7+
8+
For serial access to the console, reference this guide: :doc:`Serial Console connectivity </hardware/serial_connectivity>`
9+
10+
Console access is also possible directly when running a virtual machine or hardware with VGA capabilities.
11+
12+
This guide describes step by step how to restore a previous configuration via console.
13+
14+
.. Attention::
15+
16+
This requires automatic backups being retained. If you changed `Backup Count` settings in :menuselection:`System --> Configuration --> Backups`,
17+
the history can be too short to restore a working configuration from the local backup cache.
18+
Mounting a USB flash drive with a previous configuration might be necessary.
19+
20+
.. Tip::
21+
22+
Using :doc:`Snapshots </manual/snapshots>` with a ZFS filesystem can make rollbacks simpler.
23+
24+
25+
-----------------------------
26+
1. Power off the device
27+
-----------------------------
28+
29+
Since you need to influence the boot process to reset the configuration, you should start with powering off the (virtual) device.
30+
31+
.. Attention::
32+
33+
If you run a HA setup, ensure any cron jobs that synchronize the configuration are turned off. Otherwise they can overwrite the
34+
configuration that you restored.
35+
36+
-----------------------------
37+
2. Access console
38+
-----------------------------
39+
40+
Make sure you are able to access the (virtual) console, in case it is a physical machine you might want to connect a
41+
monitor and keyboard, when it is an appliance with serial access, make sure to connect to the serial/usb port using an application
42+
like putty.
43+
44+
.. Tip::
45+
46+
When using devices from the OPNsense shop (https://shop.opnsense.com), usually there's a mini-usb to serial cable included
47+
in the box, the :doc:`Serial Console connectivity </hardware/serial_connectivity>` guide will help you with the setup.
48+
49+
-----------------------------
50+
3. Power on and boot
51+
-----------------------------
52+
53+
Switch the power and wait for the OPNsense splash screen to appear. Do not interact with the splash screen, wait for the actual boot to start.
54+
55+
When the text scrolls fast, hold the **CTRL** button and press **C** rapidly to break out of the boot process into a shell. This does not need any
56+
authentication.
57+
58+
-----------------------------
59+
4. Replace configuration
60+
-----------------------------
61+
62+
Now that you are in the shell, you can do changes to the filesystem. In our example, we will restore a previous config.xml version.
63+
64+
First we will evaluate which config.xml version should be restored:
65+
66+
.. code-block:: sh
67+
68+
cd /conf/backup
69+
ls -la
70+
71+
Check out the timestamps of the backup configurations, copy the filename of one that was before you made the breaking change.
72+
We will backup our current config.xml and then overwrite it with a previous version.
73+
74+
.. Attention::
75+
76+
The below example must be adjusted to represent your config.xml timestamp.
77+
78+
.. code-block:: sh
79+
80+
cp /conf/config.xml /conf/config.xml.backup
81+
cp /conf/backup/config-YOURTIMESTAMP.xml /conf/config.xml
82+
83+
Reboot and the replaced configuration will be loaded.
84+
85+
.. code-block:: sh
86+
87+
reboot
88+
89+
After the reboot, confirm that you can log in and that the breaking change has been rolled back. If not, repeat the above steps and go back
90+
further with the backup configuration timestamp.
91+
92+
If this cannot fix it, :doc:`reinstall your appliance </manual/install>` with the latest available image and restore a
93+
known-good configuration you have kept safe.

0 commit comments

Comments
 (0)