[OpenWrt-Devel] [PATCH v3 0/4] base-files: add new backup options

luizluca at gmail.com luizluca at gmail.com
Fri Aug 17 19:49:49 EDT 2018


From: Luiz Angelo Daros de Luca <luizluca at gmail.com>

Today, every file listed in /etc/sysupgrade.conf, /etc/config,
marked as changed conffile and others will be in backup. Some of
these files from previous OpenWrt version might break something.
/etc/profile is a good example of what should not be in backup if
unchanged. Also, any conffile that has a new required parameter
might break after restore.

When the user changes a file, it is expected that he/she knows that
he/she is doing. The problem is when OpenWrt replaces a file with one
from a previous version that the user might not even know that it exists.

The new '-u' option asks backup to (oportunisticly) skip any file that
is equals to /rom. If a system does not have /rom, it simply does
nothing. /rom does not need to actually be squashfs. If the user is using
ext4, he/she could simply copy files into /rom before the first change
is made. IMHO, it should even be the default behavior.

A backup might also miss important files for the user. The user must
insert every single file needed in /etc/sysupgrade.conf in order to get
it into a backup. However, it is easy to simply miss one. '-c' option
does try to save everything, but limited to /etc, probably to skip code
files. Saving /overlay also works but only when restoring to an
identical OpenWrt version. The new '-o' is equivalent to saving
/overlay, but it skips any files that came from a package, except those
marked as a changed config file, sysupgrade.conf or /lib/upgrade/keep.d.
It does work with '-u', skipping files touched but reverted to the
original state.

After the user seeded a new OpenWrt with a backup generated with '-o'
and '-u', the next natural step is to reinstall all previously installed
packages. '-k' adds a file into the backup containing the list of
installed packages and also its origin (rom or overlay). It is a one-line
script to reinstall them all.

My normal upgrade procedure is:

 # sysupgrade -o -k -u openwrt-new-version.img
 # <auto reboot>
 # opkg update
 # grep "\toverlay" /etc/backup/installed_packages.txt | cut -f1 | xargs -r opkg install
 # rm /etc/backup/installed_packages.txt
 # reboot

Those options could be used by Luci, exposed to user during an upgrade.
The (re)installation step could even become automatic (on demand) or
offered to the user when Luci detects /etc/backup/installed_packages.txt
presence.

Changes from previous versions:

V2-V3:
* Rename installed packages file to /etc/backup/installed_packages.txt
* Avoid touching flash by using overlay instead of tar append hack
* Also consider Alternatives as package files
* Skip /etc/backup/installed_packages.txt from a backup without '-k'
* Send sysupgrade msgs to stderr

V1-V2:
* Ignore unchanged files from /rom became an option ('-u')
* Add '-o' to save all /overlay, except software files
* Add '-k' to save installed packages
* Minor cleanups

References:

V3
* https://github.com/luizluca/openwrt/tree/better-backups-v3

V2
* https://github.com/luizluca/openwrt/tree/better-backups-v2
* https://patchwork.ozlabs.org/cover/895208/

V1
* https://github.com/luizluca/openwrt/tree/better-backups-v1
* https://lists.openwrt.org/pipermail/openwrt-devel/2017-November/009892.html

Luiz Angelo Daros de Luca (4):
  base-files: minor cleanups on sysupgrade
  base-files: add sysupgrade -u to skip unchanged files
  base-files: add sysupgrade -o to save all overlay files
  base-files: add sysupgrade -k to save list of pkgs

 package/base-files/files/sbin/sysupgrade | 136 +++++++++++++++++++----
 1 file changed, 113 insertions(+), 23 deletions(-)

-- 
2.18.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list