Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
Development and Code Review
(Moderator:
fabian
) »
Restore opnsense's configuration via API
« previous
next »
Print
Pages: [
1
]
Author
Topic: Restore opnsense's configuration via API (Read 2403 times)
annduy
Newbie
Posts: 8
Karma: 0
Restore opnsense's configuration via API
«
on:
December 06, 2023, 06:57:42 am »
Hi all,
Now, I am able to download the latest configuration of an Opnsense box by using API at /core/backup/download/this. However, I haven't found the API for the restoration in Opnsense's document, even though in GUI we can select the area for restoration. Is there any way to make restoration (fully or partially) via API?
Thanks in advance for your advices.
AN
«
Last Edit: December 06, 2023, 08:57:52 am by annduy
»
Logged
annduy
Newbie
Posts: 8
Karma: 0
Re: Restore opnsense's configuration via API
«
Reply #1 on:
December 21, 2023, 04:38:38 am »
Hi all,
please be updated the status of my asking: after some days of googling, chatGPT, Bard,... I decide to go with another approach for restoring an opnsense backup:
1. create config.xml file on local machine
2. use scp to override config.xml of destination opnsense
3. call API from local machine to reboot the destination opnsense.
It works as my expectation. See the clip for how it works
https://youtu.be/Wz0CVxiWaw8
Merry Xmas to all,
Annduy
Logged
Vangsguard
Newbie
Posts: 7
Karma: 0
Hello, friend. Hello, friend? That's lame
Re: Restore opnsense's configuration via API
«
Reply #2 on:
December 21, 2023, 03:32:11 pm »
Hi there! Like you, I've been experimenting with the API for a while now, and I initially had no idea how to proceed due to the poorly written/generated documentation.
If the URL of the page you're on includes "/ui/" and doesn't end in ".php," it's actually using their own API for configuration. To discover which API they're using, you can press F12 to open the Network Tab. There, you can observe the different POST methods being called, understand what the payload should look like, and anticipate the response. This process isn't documented anywhere, and often you'll find API calls that aren't listed in their official documentation.
Best regards
- Vangsguard
Logged
annduy
Newbie
Posts: 8
Karma: 0
Re: Restore opnsense's configuration via API
«
Reply #3 on:
December 24, 2023, 03:14:48 pm »
Hi Vangsguard.
Thanks bro for the advice. However, unfortunately, the page "System: Configuration: Backups" is a .php file, therefore no API capability on this,
. See the attached photo for more info about this page. Anyway, I have worked around and have been able to restore a backup file (full restore) as shared in previous post. I may do some extra work for partial restoration then share with you all in this forum.
Once again, thank you so much for the advice. It should be applicable in many other situations.
Merry Xmas and Happy New Year.
Annduy
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
English Forums
»
Development and Code Review
(Moderator:
fabian
) »
Restore opnsense's configuration via API