forked from hummypkg/webif
automatic daily schedule backups
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@551 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
84b00010a8
commit
a189b524ab
17
CONTROL/postinst
Executable file
17
CONTROL/postinst
Executable 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
10
CONTROL/prerm
Executable 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
|
||||
|
@ -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]} {
|
||||
|
Loading…
Reference in New Issue
Block a user