1
0
Fork 0
qurl/backup.go

23 lines
444 B
Go
Raw Normal View History

2018-11-18 18:28:44 -09:00
package main
import (
"fmt"
2019-12-26 16:08:43 -09:00
"git.binarythought.com/cdramey/qurl/storage"
2018-11-18 18:28:44 -09:00
"os"
2019-12-26 16:08:43 -09:00
"path"
"time"
2018-11-18 18:28:44 -09:00
)
2019-12-26 16:08:43 -09:00
func manageBackup(stor storage.Storage, dir string, interval int) {
2018-11-18 18:28:44 -09:00
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())
}
}
}