23 lines
413 B
Go
23 lines
413 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"qurl/storage"
|
||
|
"time"
|
||
|
"fmt"
|
||
|
"path"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func manageBackup(stor storage.Storage, dir string, interval int){
|
||
|
for {
|
||
|
time.Sleep(time.Duration(interval) * time.Second)
|
||
|
fname := fmt.Sprintf("qurl-%s.backup",
|
||
|
time.Now().Format("20060102150405"))
|
||
|
|
||
|
err := stor.Backup(path.Join(dir, fname))
|
||
|
if err != nil {
|
||
|
fmt.Fprintf(os.Stderr, "Backup failure: %s\n", err.Error())
|
||
|
}
|
||
|
}
|
||
|
}
|