OPNsense Forum

Archive => 24.1, 24.4 Legacy Series => Topic started by: DanMauser on March 21, 2024, 05:15:28 AM

Title: Backup/Restore config.xml file using command line
Post by: DanMauser on March 21, 2024, 05:15:28 AM
Is there any way that I can backup/restore OPNSense configuration file (config.xlm) using via CLI/shell command?
Title: Re: Backup/Restore config.xml file using command line
Post by: patient0 on March 21, 2024, 08:30:42 AM
I think in the Installation Instructions (https://docs.opnsense.org/manual/install.html#installation-instructions) the paragraph "For New installations/migrations follow this process:" covers it.
Title: Re: Backup/Restore config.xml file using command line
Post by: jp0469 on March 21, 2024, 01:12:30 PM
You can copy the latest configuration from /conf/config.xml or locate a prior one in /conf/backups if available.

To restore a config, select option 13 from the CLI menu as root.
Title: Re: Backup/Restore config.xml file using command line
Post by: Vilhonator on March 21, 2024, 03:32:31 PM
There is a way, you can use scp or tftp, but neither give you option to encrypt the file, and you have to be 10000000% sure which config.xml is correct one, since restoring to old configuration is just plain copy text from old config.xml file, paste it to config.xml you want to replace and reboot your opnsense.

Anyway, opnsense by default automatically backs up old configuration whenever you make changes to local cahce and you can restore to one of those from console selecting option 13) Restore a backup.
Title: Re: Backup/Restore config.xml file using command line
Post by: franco on March 21, 2024, 04:05:11 PM
> but neither give you option to encrypt the file

# man opnsense-crypt

8)
Title: Re: Backup/Restore config.xml file using command line
Post by: DanMauser on March 21, 2024, 06:38:40 PM
> To restore a config, select option 13 from the CLI menu as root

Is there any other option to restore using a command line directly from the shell?

I need to issue a restore from a shell script; That's reason I can't use option 13.
Otherwise, I will incorporate that into the bootstrap method. Thanks all for the answers.
Title: Re: Backup/Restore config.xml file using command line
Post by: cookiemonster on March 21, 2024, 11:36:38 PM
Quote from: franco on March 21, 2024, 04:05:11 PM
> but neither give you option to encrypt the file

# man opnsense-crypt

8)
This one is news to me. Thanks! i have been tryng with base64 a few days ago and put it in the to-do list for afters.