Selecting files for preservation after sysupgrade

I know there's a lot of posts about this, as well as the Wiki, but I can't seem to get the exact behavior I want.
Essentially, how can I preserve a subdirectory but update the outer directory during reflashing with sysupgrade?

Suppose I had /root/data, with /root/data/file1, /root/data/file2, etc.
During a flash I want to update all files inside /root, but preserve the data folder.

I first tried placing /root/data/ in base-files, then doing sysupgrade -n or just sysupgrade. Without the -n flag everything was kept, and -n erased /root/data

I then tried using base-files-essential, appending /root/data/ to the end, and using the -n flag, to no avail.

I'm aware I could do

! dont/keep/this
! dont/keep/this/either

But I'm looking for a better way. Any help is greatly appreciated

By defining those files or that directory in /etc/sysupgrade.conf

For example, I am preserving the /etc/backup.stats directory (while the other files & dirs in /etc get handled quite normally in sysupgrade)

root@router5:~# cat /etc/sysupgrade.conf
## This file contains files and directories that should
## be preserved during an upgrade.

# /etc/example.conf
# /etc/openvpn/

1 Like

Will this method overwrite files during flash that:

  1. aren't included in sysupgrade.conf and
  2. have the same name as existing files?

Okay it does indeed. Doing /root/data/ did not preserve all files in the directory, but explicitly naming them did

/root/data/* should work though.

What does setting it to /root/data do? (Without end slash "/")

(For me the /etc/backup.stats nicely saves even all subdirectories with files.)

1 Like

Note that you can "debug" your sysupgrade.conf with:

$ sysupgrade -l
... for all the files to be preserved ...

Run it through grep and save yourself picking through the noise:
sysupgrade -l | grep root
for example.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.