Compare commits

...

2 Commits

Author SHA1 Message Date
hummypkg
b6ce0e3b16 fix sorting of backups
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@553 2a923420-c742-0410-a762-8d5b09965624
2011-12-09 10:57:13 +00:00
hummypkg
a189b524ab automatic daily schedule backups
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@551 2a923420-c742-0410-a762-8d5b09965624
2011-12-09 10:35:21 +00:00
5 changed files with 55 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 0.8.4
Version: 0.8.4-1
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4-1),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.1),ssmtp,anacron

17
CONTROL/postinst Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
export tmpf=/tmp/cronf.$$
# Add anacron jobs
ana=$PKG_ROOT/etc/anacrontab
grep -v 'backup/backup.jim' $ana > $tmpf
(
cat $tmpf
echo "1 30 /mod/var/mongoose/cgi-bin/backup/backup.jim"
) > $ana
$PKG_ROOT/etc/init.d/S02anacron start < /dev/null > /dev/null 2>&1 &
exit 0

10
CONTROL/prerm Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
export tmpf=/tmp/cronf.$$
ana=/mod/etc/anacrontab
grep -v 'backup/backup.jim' $ana > $tmpf
cp $tmpf $ana
exit 0

View File

@@ -13,12 +13,23 @@ puts ""
cgi_input
#cgi_dump
if {![dict exists $_cgi file]} {
puts "No filename supplied."
exit
set now [clock seconds]
set file [file tail [cgi_get file \
[clock format $now -format "auto-%Y-%b-%d-%H:%M"]]]
if {[string match {auto-*} $file]} {
# Delete any automatic backups over 7 days old.
set mt $(7 * 3600)
foreach af [glob -nocomplain "$dir/auto-*"] {
set aft [file mtime $af]
set diff $($now - $aft)
if {$diff > $mt} {
puts "Removing $af"
file delete $af
}
}
}
set file [file tail [dict get $_cgi file]]
set ffile "/$dir/$file.rbk"
if {[file exists $ffile]} {

View File

@@ -20,7 +20,18 @@ if {![file isdirectory $dir]} {
exit
}
set backups [glob -nocomplain "$dir/*.rbk"]
proc s_time {a b} {
file stat $a l
set at $l(ctime)
file stat $b l
set bt $l(ctime)
if {$at < $bt} { return -1 }
if {$at > $bt} { return 1 }
return 0
}
set backups [lsort -command s_time [glob -nocomplain "$dir/*.rbk"]]
if {![llength $backups]} {
empty