- local reader = ltn12_popen(backup_cmd:format(_keep_pattern()))
- luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % {
- luci.sys.hostname(), os.date("%Y-%m-%d")})
- luci.http.prepare_content("application/x-targz")
- luci.ltn12.pump.all(reader, luci.http.write)
+ local filelist = "/tmp/luci-backup-list.%d" % os.time()
+
+ sys.call(
+ "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
+ "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
+ "opkg list-changed-conffiles ) | sort -u > %s" % filelist
+ )
+
+ if fs.access(filelist) then
+ local reader = ltn12_popen(backup_cmd:format(filelist))
+ luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % {
+ luci.sys.hostname(), os.date("%Y-%m-%d")})
+ luci.http.prepare_content("application/x-targz")
+ luci.ltn12.pump.all(reader, luci.http.write)
+ fs.unlink(filelist)
+ end