update for Lyrebird deployment
r3105 | jgn | 2011-04-20 08:48:12 +1000 (Wed, 20 Apr 2011) | 1 line
This commit is contained in:
committed by
Douglas Clowes
parent
9acffeb772
commit
8b1d0103f4
@@ -0,0 +1,32 @@
|
||||
proc nextBackupTime {now period last} {
|
||||
upvar $last l
|
||||
set l [expr $now / $period * $period]
|
||||
return [expr $l + $period]
|
||||
}
|
||||
|
||||
proc backupCron {path {minutes 10} {days 1}} {
|
||||
global next_backup
|
||||
set now [clock seconds]
|
||||
set minutes [expr $minutes * 60]
|
||||
set days [expr $days * 24*3600]
|
||||
if {! [info exists next_backup]} {
|
||||
set next_backup(min) [nextBackupTime $now $minutes last]
|
||||
set next_backup(day) [nextBackupTime $now $days last]
|
||||
set file [clock format $now -format "$path/backupd-%m-%d.tcl"]
|
||||
if {![file exists $file]} {
|
||||
backup $file
|
||||
}
|
||||
}
|
||||
if {$now > $next_backup(min)} {
|
||||
set next_backup(min) [nextBackupTime $now $minutes last]
|
||||
set file [clock format $last -format "$path/backup-%Hh%M.tcl"]
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
if {$now > $next_backup(day)} {
|
||||
set next_backup(day) [nextBackupTime $now $days last]
|
||||
set file [clock format $last -format "$path/backupd-%m-%d.tcl"]
|
||||
}
|
||||
backup $file
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user