Whether I set the file to be saved in /etc/sysupgrade.conf or save it in the luci settings, I can't save the file with the .cfg extension

Whether I set the file to be saved in /etc/sysupgrade.conf or save it in the luci settings, I can't save the file with the .cfg extension.
I use rpi3b for openwrt
The official image file is used. Unable to save the ngrok.cfg file after upgrading the firmware caused ngrok to not run smoothly.
My files are saved in the /root/route/ directory.
I have set up the files I need to save in sysupgrade.conf.

## This file contains files and directories that should
## be preserved during an upgrade.

# /etc/example.conf
# /etc/openvpn/
/etc/rc.local
/etc/crontabs/root
/etc/banner
/usr/lib/lua/luci/view/themes/bootstrap/
/www/

But no matter what, the ngrok.cfg file will not be saved after the upgrade.
And the ngrok run file will be compressed to 600k from 1M. Obviously the file could not be executed. And the date will also become 1970.
What is going on with this? How can I save a file without losing it?
Anyone knows, or helps.
Greetings

@suyuan168, welcome to the community!

Can you clarify. It seems like you're trying to save a file in a file?

I haven't heard of a file ngrok.cfg in the default OpenWrt. Did you install something?

  • You posted the sysupgrade.conf file; but it doesn't appear that you saved that setting. Perhaps you're having a filesystem write issue?
  • Are you referring to the full path of the file? (e.g. /etc/config/ngrok.cfg and not ngrok.cfg)
1 Like

Yes, I installed ngrok on the router to be the arm running version.
I specified the save file /root/route/ngrok.cfg
The file directory I am running is /root/route instead of /etc/config
But when I upgrade the firmware, most files of /root/route can be saved normally, but the ngrok.cfg file is missing and the executable file ngrok is smaller.

Will backup recovery lose files? Will the executable file get smaller? Help me. thank you very much.

sysupgrade -l | grep -e /root

I don't see /root/route/ or anything that would cover that diectory in your sysupgrade.conf listing.

[2019/5/17 12:19:19] root@JUHEWIFI:~# cat /etc/sysupgrade.conf
[2019/5/17 12:19:19] ## This file contains files and directories that should
[2019/5/17 12:19:19] ## be preserved during an upgrade.
[2019/5/17 12:19:19] 
[2019/5/17 12:19:19] # /etc/example.conf
[2019/5/17 12:19:19] # /etc/openvpn/
[2019/5/17 12:19:19] /etc/rc.local
[2019/5/17 12:19:19] /root/route/
[2019/5/17 12:19:19] /root/iot/
[2019/5/17 12:19:19] /etc/crontabs/root
[2019/5/17 12:19:19] /etc/banner
[2019/5/17 12:19:19] /usr/lib/lua/luci/view/themes/bootstrap/
[2019/5/17 12:19:24] /www/root@JUHEWIFI:~# exit

After the command line, the files that I have written to /etc/sysupgrade.conf need to be saved are displayed. as follows

[2019/5/17 12:18:59] /root/route/NG_test.sh
[2019/5/17 12:18:59] /root/route/env.sh
[2019/5/17 12:18:59] /root/route/ngrok
[2019/5/17 12:18:59] /root/route/ngrok.cfg
[2019/5/17 12:18:59] /root/route/nohup.out
[2019/5/17 12:18:59] /root/route/run.sh

Thank you for your answer.

Obviously but no matter how I operate my ngrok.cfg file is lost after updating the firmware.
Ask everyone to help me.

sysupgrade uses tar to copy and restore the files. Checking what is generated for that archive (without performing an upgrade) may be helpful

$ sysupgrade --help
Usage: /sbin/sysupgrade [<upgrade-option>...] <image file or URL>
       /sbin/sysupgrade [-q] [-i] <backup-command> <file>

upgrade-option:
	-f <config>  restore configuration from .tar.gz (file or url)
	-i           interactive mode
	-c           attempt to preserve all changed files in /etc/
	-n           do not save configuration over reflash
	-p           do not attempt to restore the partition table after flash.
	-T | --test
	             Verify image and config .tar.gz but do not actually flash.
	-F | --force
	             Flash image even if image checks fail, this is dangerous!
	-q           less verbose
	-v           more verbose
	-h | --help  display this help

backup-command:
	-b | --create-backup <file>
	             create .tar.gz of files specified in sysupgrade.conf
	             then exit. Does not flash an image. If file is '-',
	             i.e. stdout, verbosity is set to 0 (i.e. quiet).
	-r | --restore-backup <file>
	             restore a .tar.gz created with sysupgrade -b
	             then exit. Does not flash an image. If file is '-',
	             the archive is read from stdin.
	-l | --list-backup
	             list the files that would be backed up when calling
	             sysupgrade -b. Does not create a backup file.

sysupgrade itself is a sh script, should that not provide enough insight.

I'm really trying to understand this. You do realize that you're backing-up/restoring to a location that isn't persistent, correct?

I'm not sure OpenWrt would restore a file to a non-existent location, and that likely can't be done on a restore config operation. As the device is wiped, the directory would be wiped also.

The location is already there, I have placed the file in /root/route. The files are fine when recovering, but the ngrok.cfg file is missing.

Have you created a test backup and confirmed it has the files you expect yet?

I backed up and downloaded it in luci. I was able to get the backup file I expected and I can restore the backup in luci and get the file I expected. But I just have to upgrade the firmware and choose to save the settings. My files will be lost.

Did you look in the archive to confirm the contents?

It should be a tar file. tar tvf backup.whatever to list the contents.

Yes, I have extracted the files downloaded from the luci web backup and unzipped it. Inside is what I want to back up. everything is normal.
However, if you use luci to upgrade the firmware and save the settings to upgrade the firmware. My settings will be restored, but only one of my files, ngrok.cfg, is missing.

  • Is ngrok running when you perform this firmware upgrade and save your settings?
  • If so, can you test a sysupgrade when you've ended the running ngrok process?

Thank you very much for your answer.
Yes, ngrok is running because I need to operate this device remotely. So ngrok operation is a must. I tested it and stopped running ngrok without any changes. The ngrok configuration file ngrok.cfg is still missing.

I ran into a similar problem with a file that had a .config extension. Rather than try to figure out why, I just named the file something different and with a different extension. Then it worked fine