43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"concord.hectabit.org/Hectabit/burgerbackup/lib/client"
|
||
|
"log"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
backupKey = "meow"
|
||
|
backupInterval = 43200
|
||
|
fileLocation = "database.db"
|
||
|
remoteURL = "http://localhost:8088/api/backup"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
for {
|
||
|
err, errCode := client.PerformBackup(fileLocation, backupKey, remoteURL)
|
||
|
if err != nil {
|
||
|
if errCode == 0 {
|
||
|
log.Println("[CRITICAL] Unknown in performBackup() file read:", err)
|
||
|
} else if errCode == 1 {
|
||
|
log.Println("[CRITICAL] Unknown in performBackup() content encryption:", err)
|
||
|
} else if errCode == 2 {
|
||
|
log.Println("[CRITICAL] Unknown in SendFileToServer() request creation:", err)
|
||
|
} else if errCode == 3 {
|
||
|
log.Println("[CRITICAL] Unknown in SendFileToServer() hash creation:", err)
|
||
|
} else if errCode == 4 {
|
||
|
log.Println("[CRITICAL] Unknown in SendFileToServer() request execution:", err)
|
||
|
} else if errCode == 5 {
|
||
|
log.Println("[CRITICAL] Unknown in SendFileToServer() response read:", err)
|
||
|
} else if errCode == 6 {
|
||
|
log.Println("[CRITICAL] Unknown in SendFileToServer() response marshalling:", err)
|
||
|
} else if errCode == 7 {
|
||
|
log.Println("[CRITICAL] Server sent message in SendFileToServer():", err)
|
||
|
} else {
|
||
|
log.Println("[CRITICAL] Unknown error in main():", err)
|
||
|
}
|
||
|
}
|
||
|
time.Sleep(time.Duration(backupInterval) * 1000000000)
|
||
|
}
|
||
|
}
|