2011-07-05 18:38:42 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2012-05-21 20:23:41 +00:00
|
|
|
source /mod/webif/lib/setup
|
2011-07-05 18:38:42 +00:00
|
|
|
|
|
|
|
require rsv.class
|
|
|
|
|
|
|
|
set dir /mod/var/backup
|
|
|
|
|
2013-02-09 22:46:15 +00:00
|
|
|
httpheader
|
2011-07-05 18:38:42 +00:00
|
|
|
|
2011-12-09 10:35:21 +00:00
|
|
|
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.
|
2012-04-18 20:26:34 +00:00
|
|
|
set mt $(15 * 86400)
|
2011-12-09 10:35:21 +00:00
|
|
|
foreach af [glob -nocomplain "$dir/auto-*"] {
|
|
|
|
set aft [file mtime $af]
|
|
|
|
set diff $($now - $aft)
|
|
|
|
if {$diff > $mt} {
|
|
|
|
puts "Removing $af"
|
|
|
|
file delete $af
|
|
|
|
}
|
|
|
|
}
|
2011-07-05 18:38:42 +00:00
|
|
|
}
|
|
|
|
|
2011-07-05 22:59:34 +00:00
|
|
|
set ffile "/$dir/$file.rbk"
|
2011-07-05 18:38:42 +00:00
|
|
|
|
|
|
|
if {[file exists $ffile]} {
|
|
|
|
puts "Backup file <i>$file</i> already exists."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[catch { set fd [open $ffile w] } msg]} {
|
|
|
|
puts "Error creating backup file. - $msg"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
puts "Backing up scheduled recordings and events..."
|
|
|
|
|
|
|
|
set events [rsv list]
|
|
|
|
|
|
|
|
set fields [lsort [[rsv] vars]]
|
|
|
|
|
2011-07-05 22:59:34 +00:00
|
|
|
#puts $fd "# [join $fields "\t"]"
|
2011-07-05 18:38:42 +00:00
|
|
|
|
|
|
|
foreach event $events {
|
|
|
|
puts " Backing up scheduled event '[$event name]'"
|
2011-07-05 22:59:34 +00:00
|
|
|
puts -nonewline $fd "event\t"
|
2011-07-05 18:38:42 +00:00
|
|
|
|
|
|
|
foreach f $fields {
|
2011-07-05 22:59:34 +00:00
|
|
|
if {$f eq "aulEventToRecordInfo"} { continue }
|
|
|
|
puts -nonewline $fd "[$event get $f]\t"
|
2011-07-05 18:38:42 +00:00
|
|
|
}
|
|
|
|
puts $fd ""
|
|
|
|
}
|
|
|
|
puts "Done."
|
|
|
|
|
|
|
|
puts "Backing up channel favourites..."
|
|
|
|
|
|
|
|
set grp 0
|
|
|
|
foreach res [$rsvdb query {
|
|
|
|
select eFavGroup,
|
|
|
|
TBL_FAV.eSvcType,
|
2012-05-30 19:51:20 +00:00
|
|
|
substr(szSvcName, 2) as szSvcName,
|
|
|
|
favIdx
|
2011-07-05 18:38:42 +00:00
|
|
|
from TBL_FAV join TBL_SVC using (hSvc)
|
2012-05-30 19:51:20 +00:00
|
|
|
order by eFavGroup, favIdx
|
2011-07-05 18:38:42 +00:00
|
|
|
}] {
|
|
|
|
if {$res(eFavGroup) != $grp} {
|
|
|
|
set grp $res(eFavGroup)
|
|
|
|
puts " Group $grp"
|
|
|
|
}
|
|
|
|
puts " $res(szSvcName)"
|
2012-05-30 19:51:20 +00:00
|
|
|
puts $fd "fav\t$res(eFavGroup)\t$res(eSvcType)\t$res(szSvcName)\t$res(favIdx)"
|
2011-07-05 18:38:42 +00:00
|
|
|
}
|
|
|
|
puts "Done."
|
|
|
|
|
|
|
|
close $fd
|
|
|
|
rsv cleanup
|
|
|
|
|