You are here

Backup node settings

7 posts / 0 new
Last post
DL1MDR
Backup node settings

I want to backup/export the settings on an AREDN-Node to be able to restore/import them in case the node has to be set up new. How can I do this?

Thanks for any help, Markus.

nc8q
nc8q's picture
Backup node settings
Hi, Markus:
Store the web pages displaying settings and restore the values manually when needed.
73, Chuck

 
KG7LMI
KG7LMI's picture
Re: possible approach

I have the same question, and I have been meaning to try the following for a while, but have been too busy to test it.

1. ssh to the node
2. run sysupgrade -b <file> to save the configuration 
3. scp the backup file to another location (if the node is reimaged this backup file will be lost)

From experience, I know that this works for OpenWRT, anyway. The issue is if everything AREDN needs is saved in the backup file. The /etc/sysupgrade.conf file determines what is backed up, and my assumption has always been that it does not cover everything required to restore an AREDN node to its previous state. However, I don't know how close it does or does not get. You might want to try this and report back, or perhaps someone has tried this already and figured out what needs to be in the config file. No reason IMHO that this process cannot be made to work with the right entries in /etc/sysupgrade.conf, if indeed they are not already there.

73, Rob


 

nc8q
nc8q's picture
if everything AREDN needs is saved in the backup
Hi, Rob:

I looked into the 'sysupgrade' command and it seems to read /etc/sysupgrade.conf for a list of files to backup.
It seems that all the lines in the default /etc/sysupgrade.conf are 'commented-out'.
There is a /etc/arednsysupgrade.conf file but I don't see how to tell sysupgrade to read it.
So, I came up with this concept and sample code:

## A sample backup script using the sysupgrade CLI command.
## Does not write an OS image

ssh -p2222 root@<nodename>
sh prep-sysupgrade.sh
sysupgrade -b backup.tar.gz
scp backup.tar.gz <username>@<workstation-name>:/home/<username>/backup.tar.gz
-----

## A sample restore script from a sysupgrade CLI command backup.
## Does not write an OS image

scp -P2222 backup.tar.gz root@<nodename>:/tmp/backup.tar.gz
ssh -p2222 root@<nodename>
sysupgrade -r /tmp/backup.tar.gz
-----

#prep-sysupgrade.sh:
arednsysupgrade_size=$(wc -c < "/etc/arednsysupgrade.conf")
#echo "$arednsysupgrade_size"
sysupgrade_size=$(wc -c < "/etc/sysupgrade.conf")
#echo "$sysupgrade_size"
if [ $arednsysupgrade_size -ge $sysupgrade_size ]; then
    echo "appending /etc/arednsysupgrade.conf to /etc/sysupgrade.conf"
    cat /etc/sysupgrade.conf /etc/arednsysupgrade.conf > /tmp/sysupgrade.conf
    cp /tmp/sysupgrade.conf /etc/sysupgrade.conf
#    rm /tmp/sysupgrade.conf
else
    echo "sysupgrade.conf has already been appended"
fi
#ls -l /etc/*upgrade.conf


73, Chuck
 
KG7LMI
KG7LMI's picture
Re: sysupgrade

Chuck,

Thanks for looking into this. I had not seen the AREDN backup config file before. You've motivated me to get off the stick and look into this in more depth wink.

I haven't tried running your script, but just based on inspection it looks fine. However, the question I cannot answer is, "How is /sbin/sysupgrade used in the AREDN upgrade process?" The comments in /etc/arednsysupgrade.conf  imply that it is used in place of (or, more likely, in addition to) /etc/sysupgrade.conf when /sbin/sysupgrade is called. My concern is: if the normal backup config file is overlaid with the AREDN one, there could be duplication or other unintended consequences.

/sbin/sysupgrade is a shell script itself, so I looked at it to see if you can specify an environment variable for the config file, but /etc/sysupgrade.conf is hard-coded into the script. Too bad, as that would be an easy way to do this.

So, if we want to be conservative, and leave everything in the original state after doing a backup, we could create a shell script as simple as:

# ln -s -b arednsysupgrade.conf sysupgrade.conf
# sysupgrade -b /tmp/backup.tar.gz
#  mv sysupgrade.conf~ sysupgrade.conf

... which leaves the original state intact. Thoughts?

73, Rob


 

nc8q
nc8q's picture
duplication or other unintended consequence

Hi, Rob:

"How is /sbin/sysupgrade used in the AREDN upgrade process?"

Yes, yes, this is a core item.

sysupgrade is mentioned 'in the docs'.
We know that much about how AREDN uses it.

https://openwrt.org/docs/techref/sysupgrade

"if the normal backup config file is overlaid with the AREDN one, there could be duplication or other unintended consequences."
There are no actionable lines in my sysupgrade.conf file, so how could there be a duplication?

"Parse command line and validate no mutually exclusive options passed."
There is some error checking built into OpenWRT's sysupgrade script.

If you edit/alter the sysupgrade.conf file, then expect consequences.
Intended or otherwise. ;-)

73, Chuck
 

KG7LMI
KG7LMI's picture
I am aware of the use of


I am aware of the use of sysupgrade to do manual installs, and I have done this previously on Mikrotik hAPs.

My concern is how the upgrade process invoked from the Administration page uses the sysupgrade command. Specifically, when you select the option to keep your settings and select "Download" on the menu, what options are being passed to sysupgrade? Clearly, the AREDN file you mentioned earlier is being used, but how is this interposed, esp. as there is no command line option for this? My concern is if:

1. the /etc/backup.conf file is still pulled in
2. nothing happens in the normal AREDN upgrade process because there are no files listed there currently
3. copying /etc/arednbackup.conf into /etc/backup.conf (and leaving it there) could cause each operation listed in /etc/arednbackup.conf to be done twice or create some sort of error

I have no idea if this is an issue or not, but it at least seems plausible. One of these days I need to start reading the source code.

So, to accomplish the simple task of creating a backup including all settings, as the OP asked, seems like we are in agreement that /etc/backup.conf should not remain in a modified state.

So here is a simple script that will create the backup file but leave /etc/backup.conf unmodified:

---

#!/bin/bash
# creates a config file that can be used with the OpenWRT command sysupgrade to restore
# the configuration of an AREDN node
#
 
if [ $1 ]; then
   REMOTE_HOST="$1"
else
  echo "Usage $0: remote_host_ip_address <local directory>"
  exit 1
fi
 
if [ $2 ]; then
   LOCAL_DIRECTORY="$2"
else
   LOCAL_DIRECTORY=.
fi
 
ssh -p 2222 -oHostKeyAlgorithms=+ssh-rsa root@$REMOTE_HOST "(cd /etc; \
   ln -s -b arednsysupgrade.conf sysupgrade.conf && \
   sysupgrade -b /tmp/$REMOTE_HOST-backup.tar.gz && \
   mv sysupgrade.conf~ sysupgrade.conf; )"
 
scp -P 2222 -oHostKeyAlgorithms=+ssh-rsa root@$REMOTE_HOST:/tmp/$REMOTE_HOST-backup.tar.gz $LOCAL_DIRECTORY
---

Note that this leaves the backup file in /tmp, which I prefer, but easy to delete it in the script if not.

<Edit>
I just did a quick test on one of my test nodes. After doing a "reset to firstboot" I copied the backup file to the node and ran sysupgrade -r to restore the settings. I had not changed many settings, but all of the ones I had changed were successfully restored to the saved values. Thus, the process appears to be sound.

73, Rob



 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer