OpenWrt Forum Archive

Topic: Preserving configs with sysupgrade -c ?

The content of this topic has been archived on 7 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm a little confused, how to preserve my configs when I reflash with sysupgrade. I intend to recompile  my trunk firmware just to get traceroute6-support and have to reflash then.

I read, I can populate /etc/sysupgrade.conf with files and directories I'd like to preserve. But to be sure, not to forget files I changed, it seems to be the easiest way to use 'sysupgrade -c' instead.

The command-help says:
-c attempt to preserve all changed files in /etc/

Will files like /etc/configs/firewall reliably be preserved by -c, or is it just an "attempt" and beta-feature?

Are directories like /root not matched by -c, because this option preserves /etc/ exclusively?

What would you recommend, sysupgrade -c or just sysupgrade?

(Router is D-Link DIR-300 B1 with OpenWrt r27711)

(Last edited by Hank on 26 Jul 2011, 12:51)

For a simple upgrade, default options will probably suffice. But if you really want to make sure all the files are preserved (including those NOT in /etc), then you can create a tar.gz archive of the files and use -f option.

Thanks for your comment, gulikoza.

gulikoza wrote:

For a simple upgrade, default options will probably suffice.

I wonder, what these suffice default options are. Looking inside the script /sbin/sysupgrade these are ...

export SAVE_CONFIG=1
export SAVE_OVERLAY=0

and the default /etc/sysupgrade.conf is empty on my system:

## This file contains files and directories that should
## be preserved during an upgrade.
# /etc/example.conf
# /etc/openvpn/

Using option -c additionally activates saving the OVERLAY:

-c) export SAVE_OVERLAY=1;;

To my understanding CONFIG means content in /etc/config/, which is handled by uci. But how do I know, there is no important data on OVERLAY, that is worth preserving too?

I do not understand the full filesystem-architecture of OpenWrt yet (noob), so wouldn't it be safe to use -c when unsure?

I know, I could do trial & error, but configs are holy and I don't want to play with them ;-) if there is a known best-practise.

gulikoza wrote:

But if you really want to make sure all the files are preserved (including those NOT in /etc), then you can create a tar.gz archive of the files and use -f option.

... does this mean, I make an archive.tar.gz of /etc and /root for example and sysupgrade -f archive.tar.gz will flash the router and afterwards restores the configs from this archive?

Thanks

(Last edited by Hank on 26 Jul 2011, 13:58)

The list of files preserved is by default in /lib/upgrade/keep.d. Additionally files returned by 'opkg list-changed-conffiles' are also preserved.

SAVE_OVERLAY saves complete /overlay directory (this is the writable part of the filesystem that gets merged with /rom to create a uniform / tree). /overlay contains changed config files, additional packages installed and anything that was written to the router. There's no rule what needs to be saved...sometimes I install additional packages but then include them in the later firmware builds, so I don't have to preserve those. Sometimes files are modified and the new firmware already contains the modifications so those are also not needed. But config files are needed or router will boot with default settings. But those are preserved by default (unless using -n).

... does this mean, I make an archive.tar.gz of /etc and /root for example and sysupgrade -f archive.tar.gz will flash the router and afterwards restores the configs from this archive?

That's what is says: 'restore configuration from .tar.gz (file or url)'. Anything archived in the tgz will be written to /overlay after the flash. This way you can hand-pick the files that will be the system after new firmware boot.

Great explanation, gulikoza, many thanks!

So these will be the files that are preserved by default on my system just doing systemupgrade without any options:

from /lib/upgrade/keep.d/base-files
/etc/shadow
/etc/config/
/etc/dropbear/
/etc/crontabs/

from /lib/upgrade/keep.d/base-files-essential
/etc/hosts
/etc/inittab
/etc/group
/etc/passwd
/etc/profile
/etc/shells
/etc/sysctl.conf
/etc/rc.local

from /lib/upgrade/keep.d/firewall
/etc/firewall.user

from opkg list-changed-conffiles
/etc/passwd
/etc/config/network
/etc/dropbear/dropbear_rsa_host_key
/etc/dropbear/dropbear_dss_host_key
/etc/config/firewall

But these files are probably not preserved and lost after sysupgrade on my system:

/overlay/etc/config/firewall.orig (a backup-copy I made)
/overlay/etc/config/gw6c.orig (a backup-copy I made)
/overlay/etc/rc.d/S45firewall (lost or persistent?)
/overlay/etc/rc.d/S45gw6c (lost or persistent?)
/overlay/root/.ssh/known_hosts

Or will the startlinks for the firewall and gw6c (gogo6-client) be recreated after the reflash? (Both packages are compiled static in the firmware)

(Last edited by Hank on 26 Jul 2011, 15:48)

Success! Reflash works as expected. Traceroute6 is now available and the firewall, gw6c and dropbear are coming up as before.

With: root@OpenWrt:~# sysupgrade openwrt-ramips-rt305x-dir-300-b1-squashfs-sysupgrade.bin

Thanks again for your help and scruffy for editing the Wiki instantly!

cheers

Actually it was an inviation... whenever you want to edit => go wiki, go

The discussion might have continued from here.