modules/admin-full: reuse sysupgrade facilities to create backup archive
This commit is contained in:
parent
5e4d4ff5ef
commit
abb201ab57
1 changed files with 7 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
||||||
LuCI - Lua Configuration Interface
|
LuCI - Lua Configuration Interface
|
||||||
|
|
||||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||||
Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal.org>
|
Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -186,7 +186,7 @@ function action_flashops()
|
||||||
local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
|
local reset_avail = os.execute([[grep '"rootfs_data"' /proc/mtd >/dev/null 2>&1]]) == 0
|
||||||
|
|
||||||
local restore_cmd = "tar -xzC/ >/dev/null 2>&1"
|
local restore_cmd = "tar -xzC/ >/dev/null 2>&1"
|
||||||
local backup_cmd = "tar -czT %s 2>/dev/null"
|
local backup_cmd = "sysupgrade --create-backup - 2>/dev/null"
|
||||||
local image_tmp = "/tmp/firmware.img"
|
local image_tmp = "/tmp/firmware.img"
|
||||||
|
|
||||||
local function image_supported()
|
local function image_supported()
|
||||||
|
@ -249,20 +249,11 @@ function action_flashops()
|
||||||
--
|
--
|
||||||
-- Assemble file list, generate backup
|
-- Assemble file list, generate backup
|
||||||
--
|
--
|
||||||
local filelist = "/tmp/luci-backup-list.%d" % os.time()
|
local reader = ltn12_popen(backup_cmd)
|
||||||
sys.call(
|
luci.http.header('Content-Disposition', 'attachment; filename="backup-%s-%s.tar.gz"' % {
|
||||||
"( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " ..
|
luci.sys.hostname(), os.date("%Y-%m-%d")})
|
||||||
"/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " ..
|
luci.http.prepare_content("application/x-targz")
|
||||||
"opkg list-changed-conffiles ) | sort -u > %s" % filelist
|
luci.ltn12.pump.all(reader, luci.http.write)
|
||||||
)
|
|
||||||
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
|
|
||||||
elseif luci.http.formvalue("restore") then
|
elseif luci.http.formvalue("restore") then
|
||||||
--
|
--
|
||||||
-- Unpack received .tar.gz
|
-- Unpack received .tar.gz
|
||||||
|
|
Loading…
Reference in a new issue