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

2018-08-23 Thread Tom Psyborg
Unrelated to upgrade. I have dnsmasq and ntpd script disabled, i make a
backup, then reset my device to defaults or flash some other image without
keeping settings. After flashing back image version from which the backup
was made and restoring backup, dnsmasq and ntpd are enabled again. So these
settings were not backed up. Not even after your changes. I've checked
backup file and there are no initscripts inside it.

I did not apply your patch 4 that concerns packages auto installation. I
think you should drop that one.

On 20 August 2018 at 14:42, Luiz Angelo Daros de Luca 
wrote:

>
> I've just realised this ain't what I thought. This concerns upgrade, but
>> I've missed it for backup/restore option. Sorry for bothering.
>>
>
> Tom, it's both. In an upgrade process, files are preserved using a
> backup/restore procedure.
> --
>
> Luiz Angelo Daros de Luca
> luizl...@gmail.com
>
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


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

2018-08-20 Thread Luiz Angelo Daros de Luca
Hi Tom,

> Unrelated to upgrade. I have dnsmasq and ntpd script disabled, i make a 
> backup, then reset my device to defaults or flash some other image without 
> keeping settings. After flashing back image version from which the backup was 
> made and restoring backup, dnsmasq and ntpd are enabled again. So these 
> settings were not backed up. Not even after your changes. I've checked backup 
> file and there are no initscripts inside it.

It's an interesting situation. init system, from sysv to systemd (and
including procd) uses symlinks for service activation. If there is a
link starting with "S" at /etc/rc.d/ and it is executable, service is
enabled and it will run. When you disable a service, you get that link
removed. You can check /etc/rc.common for code.

A backup is just a tarball with files. It does not make sense to have
tarball that removes a file when extracted.

As a (not tested) suggestion, you could replace thoses link with a
broken ones, like:

ln -sf disabled /etc/rc.d/S19dnsmasq
ln -sf disabled /etc/rc.d/K19dnsmasq
ln -sf disabled /etc/rc.d/S98sysntpd
ln -sf disabled /etc/rc.d/K98sysntpd

(maybe this should be the default behavior of rccommon disable())

Another alternative is to create a startup script that tries to
disable those services on every boot.

Both might work.

> I did not apply your patch 4 that concerns packages auto installation. I 
> think you should drop that one.

It does not autoinstall packages. If a user asked for it, it only
saves a list of installed packages to help reinstalling them.

Regards,
---
 Luiz Angelo Daros de Luca
luizl...@gmail.com

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


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

2018-08-17 Thread luizluca
From: Luiz Angelo Daros de Luca 

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
 # 
 # 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@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel