Backup/Restore config.xml file using command line

Started by DanMauser, March 21, 2024, 05:15:28 AM

Previous topic - Next topic
Is there any way that I can backup/restore OPNSense configuration file (config.xlm) using via CLI/shell command?

I think in the Installation Instructions the paragraph "For New installations/migrations follow this process:" covers it.
Deciso DEC740

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.

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.

> but neither give you option to encrypt the file

# man opnsense-crypt

8)

> 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.

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.