Restore previus configuration from USB
I was working around with the file editor over web GUI (Pfsense version 2.3.5) make it some changes. I make a mistake and the system show me a error and i couldn't enter again. So, i tryed to fix the problem by restore a backup made it previusly before start working on the config file (this is important guys, do a backup everytime you want to change some in any system :)). Several minutes later and trying many methods i couldn't restore my system, mostly becouse the backup file was in a usb drive and the installation program show me several errors trying to restore the config.xml. By the way, even using the Restore to factory default i wasn't able to restore my box. After think for a minute, this was the method that work for me. Maybe is not the most elegant but, it works pretty good :)
1-. Conect your usb drive with the file .xml. Then enter the shell (option 8 )
2-. Find out the device with ls /dev/da*. Probably it's looks like da(x)s(x).
3-. Mount the drive. I created a directory on /home with mkdir (something like mkdir /home/usbdrive)
4-. Go to the USB drive via cd /home/usbdrive/ <directory_where_the_file_is>5-. Type cp <name_of_the_file>.xml /cf/conf
6-. Go to /cf/conf/ and using vi open the file config.xml. "vi config.xml"
7-. Press Shift + q. When the ":" appears type "write config_old.xml" (This make a copy of the original config.xml, just in case)
8-. Now open the backup file with vi. Press Shift + q, and when the ":" appears type "write! config.xml". (Overwrite the config.xml)
9-. Then reboot the system with "reboot" command.
And thats it. Your system should run normaly again.
I would like to know is there is a more easly way to restore a config.xml.
PS: As you probably notice, i'm not a Linux/Unix user. I toke some minutes to find out the commands to do this.
PS2: This method allow you to enter to configuration web gui. But, i saw that if you try to change anything using edit file and click on "save", the changes are not saved. So, once you successfuly log in in the configuration gui, you may make a restore using a previus backup.
KOM last edited by
Perhaps you should post your question in one of the support forums, General Questions maybe?
Is not a question really, i'm just sharing a solution to a problem i haved. But, if any one want to share a better idea how to solve this kind of issues are welcome. :)
"I would like to know is there is a more easly way to restore a config.xml. "
If your at the console or ssh you can just restore previous config from there.. It will list time and date of config change and pick one before you messed up the config… I would not suggest editing the xml file directly btw..
In fact i tried that method, but the error in the config file would't let me use it.
And yes, is a very good advice dont work around with the config.xml. But, is important know the file and know how to work with it, because in some scenarios, is the best way to achive time saving. :)
Yes it is possible to edit the xml - but I sure wouldn't edit it with the web editor on pfsense itself ;) download, modify whatever you need and then restore that section or all of it, etc.
Well yeah if you corrupted the xml then you might have a problem ;) You really shouldn't be messing with config of pfsense outside of the gui, unless you really know what your doing and have a backup ready ;)
NogBadTheBad last edited by
notepad++ makes things easier, it understands xml
I have edited xml and restored it.. I just use pspad on windows - like it better than notepad++ Just did this to restore all my host overrides on a move from my VM to the sg4860.. Real time saver, etc.. even though I had to edit the interfaces in the xml, etc.
I have moved certs this way from cert manager, etc. It is a viable solution - but would never think to try and edit the xml on the fly with the web editor ;) Then again I have been using pfsense for 10 years and fairly familiar with its workings ;)
Whatever you do, have a backup from before you started editing it.
Exactly - that is a given on anything you edit.. Be it a word doc or a excel spreadsheet, or a config from your cisco router or your html, etc. etc.. Never directly edit the original - that is asking for trouble… Always work with a copy..