Persistent folder after updates

Hi everyone, I created a script that creates a txt file in a folder. The problem is that this folder and its contents, a log.txt file, get lost every time I update OpenWrt. I tried both in /root/ and /etc/
but without fixing the problem. So the question is: Is there a folder I can use to save a log.txt file that won't get lost with every update? Thanks for the answers.

edit /etc/sysupgrade.conf and it will be saved :slight_smile:

you could add /root and save the whole directory, makes sense if you keep notes there

Like aboaboit implies, you need to define that file or whole directory to be backuped.

OpenWrt backups (and preserves in a sysupgrade) only those directories & files that are specifically defined as config files/directories or specifically declared as backup-targets. You need to add your file to that list, if you want something to be preserved.
User editable extra files list is in /etc/sysupgrade.conf

Make sure to validate your changes to the config with sysupgrade's "list backup" option. I usually run it through grep to filter out the other 100+ entries, just to see if my changes took hold:

$ grep '\.config' /etc/sysupgrade.conf
/root/.config/

$ sysupgrade -l | grep '\.config'
/root/.config/btop/btop.conf
/root/.config/btop/btop.log
/root/.config/htop/htoprc

Hi,
Can you confirm that there's no folder that's natively persistent after upgrades, and that the only way to get one is to edit the sysupgrade.conf file?

Thank's again

No and no.

There are directories like /etc/config that are defined to be "conffiles" for sysupgrade backups.

There are several definition mechanisms, e.g. defining "conffiles" in package Makefile, so the /etc/sysupgrade.conf is the user-friendly mechanism to define new ones.

You can run "sysupgrade -l" to check what files & dirs are currently defined in total.

-l | --list-backup
                     list the files that would be backed up when calling
                     sysupgrade -b. Does not create a backup file.

But the point is that in normal routers, the sysupgrade overwrites the whole firmware partition including all your changes, and the backup of specified files from ramdisk is then added after flashing, before the post-flash reboot. So, by default all old files get destroyed. (Not true for hard disk based x86 images etc., but valid for normal embedded flash)

This is the output so seem to be ok.

root@magellan:~# sysupgrade -l
/root/wan_ip/wan_ip_log.txt
root@magellan:~#

That actually looks suspiciously short.
There should normally be the config files from /etc/config , profile etc. stuff from /etc, and possibly some extra file defined by packages like /etc/luci_statistics in my example below...

 OpenWrt SNAPSHOT, r34578-d51fa9b28e
 -----------------------------------------------------
 10:31:31 up 1 day, 12:20,  load average: 0.00, 0.00, 0.00
root@router6000:~# sysupgrade -l
/etc/collectd.conf
/etc/config/WPA3FT_VHT
/etc/config/WPA3FT_broken
/etc/config/WPA3FT_kokeilu
/etc/config/WPA3FT_mini
/etc/config/WPA3FT_toimii
/etc/config/adblock
/etc/config/attendedsysupgrade
/etc/config/banip
/etc/config/bcp38
/etc/config/collectd
/etc/config/dhcp
/etc/config/dropbear
/etc/config/firewall
/etc/config/fstab
/etc/config/irqbalance
/etc/config/luci
/etc/config/luci_plugins
/etc/config/luci_statistics
/etc/config/network
/etc/config/network-blanko
/etc/config/network.original
/etc/config/network.toimii13032026
/etc/config/nlbwmon
/etc/config/openssl
/etc/config/qosify
/etc/config/radius
/etc/config/rpcd
/etc/config/sqm
/etc/config/system
/etc/config/system-blanko
/etc/config/system.original
/etc/config/ubihealthd
/etc/config/ubootenv
/etc/config/ucitrack
/etc/config/uhttpd
/etc/config/usteer
/etc/config/wireless
/etc/config/wireless.030502026
/etc/config/wireless.25092025
/etc/config/wireless.original
/etc/config/wireless.testing04052026
/etc/crontabs/root
/etc/dropbear/authorized_keys
/etc/dropbear/dropbear_ecdsa_host_key
/etc/dropbear/dropbear_ed25519_host_key
/etc/dropbear/dropbear_rsa_host_key
/etc/fw_env.config
/etc/group
/etc/hosts
/etc/inittab
/etc/luci-uploads/.placeholder
/etc/nftables.d/10-custom-filter-chains.nft
/etc/nftables.d/README
/etc/passwd
/etc/profile
/etc/profile.d/00-passwordless-root.sh
/etc/profile.d/busybox-history-file.sh
/etc/profile.d/nano-default-editor.sh
/etc/profile.d/show-uptime.sh
/etc/radius/clients
/etc/radius/users
/etc/rc.local
/etc/shadow
/etc/shells
/etc/shinit
/etc/sysctl.conf
/etc/uhttpd.crt
/etc/uhttpd.key
/etc/unetd/unet.bin
/etc/luci_statistics/rrdbackup.sysupgrade.tgz
/etc/luci_statistics/sysupgrade.trustme.txt

If you have intentionally tried to remove all those and just added that one file, then your list is ok.

Default list comes from /lib/upgrade/keep.d/* and the package specifics do come from each package in opkg/apk database.

If your list is complete empty, I do wonder which OpenWrt version you are running? Normal router, with normal official OpenWrt? (not some OEM fork like GL-iNet's?)

Correct. I intentionally remove all remain entry but my file it contain a list very similar to your.