Netgate Store

Author Topic: Restore previus configuration from USB  (Read 461 times)

0 Members and 1 Guest are viewing this topic.

Offline Reeko

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Restore previus configuration from USB
« on: January 24, 2018, 03:14:25 pm »
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. 

Greetings
« Last Edit: January 26, 2018, 06:18:03 am by Reeko »

Offline KOM

  • Hero Member
  • *****
  • Posts: 5937
  • Karma: +724/-24
    • View Profile
Re: Restore previus configuration from USB
« Reply #1 on: January 26, 2018, 08:27:07 am »
Perhaps you should post your question in one of the support forums, General Questions maybe?

Offline Reeko

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Restore previus configuration from USB
« Reply #2 on: January 31, 2018, 07:24:56 am »
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.  :)

Online johnpoz

  • Hero Member
  • *****
  • Posts: 16017
  • Karma: +1527/-221
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: Restore previus configuration from USB
« Reply #3 on: January 31, 2018, 07:37:13 am »
"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..

- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- Please don't PM me for personal help
- if you want to say thanks applaud or https://www.freebsdfoundation.org/donate/
1x SG-2440 2.4.3-RELEASE (work)
1x SG-3100 2.4.3-RELEASE (work)
1x SG-4860 2.4.3-RELEASE-p1 (home)

Offline Reeko

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Restore previus configuration from USB
« Reply #4 on: February 01, 2018, 09:50:45 am »
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.  :)

Online johnpoz

  • Hero Member
  • *****
  • Posts: 16017
  • Karma: +1527/-221
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: Restore previus configuration from USB
« Reply #5 on: February 02, 2018, 11:27:34 am »
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 ;)
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- Please don't PM me for personal help
- if you want to say thanks applaud or https://www.freebsdfoundation.org/donate/
1x SG-2440 2.4.3-RELEASE (work)
1x SG-3100 2.4.3-RELEASE (work)
1x SG-4860 2.4.3-RELEASE-p1 (home)

Offline NogBadTheBad

  • Hero Member
  • *****
  • Posts: 639
  • Karma: +51/-0
    • View Profile
Re: Restore previus configuration from USB
« Reply #6 on: February 06, 2018, 03:31:24 pm »
notepad++ makes things easier, it understands xml

Online johnpoz

  • Hero Member
  • *****
  • Posts: 16017
  • Karma: +1527/-221
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: Restore previus configuration from USB
« Reply #7 on: February 06, 2018, 03:38:46 pm »
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 ;)
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- Please don't PM me for personal help
- if you want to say thanks applaud or https://www.freebsdfoundation.org/donate/
1x SG-2440 2.4.3-RELEASE (work)
1x SG-3100 2.4.3-RELEASE (work)
1x SG-4860 2.4.3-RELEASE-p1 (home)

Offline Derelict

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10552
  • Karma: +1208/-324
    • View Profile
Re: Restore previus configuration from USB
« Reply #8 on: February 06, 2018, 03:43:03 pm »
Whatever you do, have a backup from before you started editing it.
Las Vegas, Nevada, USA
Use this diagram to describe your issue.
The pfSense Book is now available for just $24.70!
Do Not PM For Help! NO_WAN_EGRESSTM

Online johnpoz

  • Hero Member
  • *****
  • Posts: 16017
  • Karma: +1527/-221
  • Not a pfSense employee, they cannot fire me...
    • View Profile
Re: Restore previus configuration from USB
« Reply #9 on: February 06, 2018, 04:03:51 pm »
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..
- An intelligent man is sometimes forced to be drunk to spend time with his fools.
- Please don't PM me for personal help
- if you want to say thanks applaud or https://www.freebsdfoundation.org/donate/
1x SG-2440 2.4.3-RELEASE (work)
1x SG-3100 2.4.3-RELEASE (work)
1x SG-4860 2.4.3-RELEASE-p1 (home)