ZebMcKayhan
Very Senior Member
This is a continuation of a discussion sparked by @jsbeddow here.
This have been requested a couple of times, by me as well so I figured it is time to write down something to get things going. However, I only have 1 router and Im not planning on doing any factory reset any time soon and I am very dependant on my Wireguard Server so I will not be able to restore any NVRAM variables, instead I am hoping there are people here that have the ability to try it out and report back. I will try to keep these instructions as updated as I can.
This is my understand of what should be needed to get this done:
1. Install @Martinski script for saving subset of NVRAM variables:
2. Download the sample config for convenience:
3. Edit the config to enable storing the Wireguard server NVRAM parameters (only):
scroll down to:
and change to:
Save & Exit (Cntrl+x, y, [ENTER])
let all others be commented as we dont want to migrate more nvram parameters than we need.
4. Run the script in menu mode:
Check under "dp" option so the path for saving backups are correct and proper. choose something differently if needed by selecting this option.
Check under "fl" that the config file we edited are used, if not, adjust by selecting this option.
5. For backing up your Wireguard server, select option "bk". If everything is alright, the script will output each NVRAM variable its backing up. For sanity check, there should be 10 entries for the server peer itself and additionally 9 entires for each client peer. in my case with the server and 2 client I have 28 entires backed up.
If you even want to double check which NVRAM variables are included in a backup file, use option "ls".
6. When you need to restore your wireguard server after a factory reset for example, you will need to install the script again (repeat #1). You dont need the config file to restore but I recommend to do the whole install (#1 - #3) as you probably want to continue your backup from the new router state.
In the script, make sure option "dp" points to where the backups are from your previous backup.
To start restore, select option "rt". You will be prompted about which backup file in the target you wish to restore.
Reboot your router after a restoration.
As I have not been able to do this myself, I cannot tell you for sure it is working so if anyone tries this, please report back with your router model and FW version.
Im not sure if entware needs to be installed or not, perhaps @Martinski could answer if his script have this dependecy?
This have been requested a couple of times, by me as well so I figured it is time to write down something to get things going. However, I only have 1 router and Im not planning on doing any factory reset any time soon and I am very dependant on my Wireguard Server so I will not be able to restore any NVRAM variables, instead I am hoping there are people here that have the ability to try it out and report back. I will try to keep these instructions as updated as I can.
This is my understand of what should be needed to get this done:
1. Install @Martinski script for saving subset of NVRAM variables:
Code:
mkdir -m 755 -p /jffs/addons/SaveRestoreNVRAM
curl -kLSs --retry 3 --retry-delay 5 --retry-connrefused https://raw.githubusercontent.com/Martinski4GitHub/CustomMiscUtils/master/NVRAM/SaveRestoreNVRAMvars.sh -o /jffs/addons/SaveRestoreNVRAM/SaveRestoreNVRAMvars.sh && chmod 755 /jffs/addons/SaveRestoreNVRAM/SaveRestoreNVRAMvars.sh
2. Download the sample config for convenience:
Code:
curl -kLSs --retry 3 --retry-delay 5 --retry-connrefused https://raw.githubusercontent.com/Martinski4GitHub/CustomMiscUtils/master/NVRAM/NVRAM_VarList_SAMPLE.txt -o /jffs/addons/SaveRestoreNVRAM/NVRAM_VarList.txt
3. Edit the config to enable storing the Wireguard server NVRAM parameters (only):
Code:
nano /jffs/addons/SaveRestoreNVRAM/NVRAM_VarList.txt
Code:
#------------------#
# WireGuard Server #
#------------------#
# wgs_.*
# wgs1_.*
# wgsc_.*
Code:
#------------------#
# WireGuard Server #
#------------------#
# wgs_.*
wgs1_.*
# wgsc_.*
let all others be commented as we dont want to migrate more nvram parameters than we need.
4. Run the script in menu mode:
Code:
/jffs/addons/SaveRestoreNVRAM/SaveRestoreNVRAMvars.sh -menu
Check under "fl" that the config file we edited are used, if not, adjust by selecting this option.
5. For backing up your Wireguard server, select option "bk". If everything is alright, the script will output each NVRAM variable its backing up. For sanity check, there should be 10 entries for the server peer itself and additionally 9 entires for each client peer. in my case with the server and 2 client I have 28 entires backed up.
If you even want to double check which NVRAM variables are included in a backup file, use option "ls".
6. When you need to restore your wireguard server after a factory reset for example, you will need to install the script again (repeat #1). You dont need the config file to restore but I recommend to do the whole install (#1 - #3) as you probably want to continue your backup from the new router state.
In the script, make sure option "dp" points to where the backups are from your previous backup.
To start restore, select option "rt". You will be prompted about which backup file in the target you wish to restore.
Reboot your router after a restoration.
As I have not been able to do this myself, I cannot tell you for sure it is working so if anyone tries this, please report back with your router model and FW version.
Im not sure if entware needs to be installed or not, perhaps @Martinski could answer if his script have this dependecy?