Files
factoryman/backup.go
Raum0x2A b2c534f29b Fixes Changes and new additions
Fixed an issue where launching server w/o screen failed
New: added an output showing screen sessions after launching
New: added stdout and stdin to screenless launch allowing interacting with server cli
Change: Broke up source code to make it easier to read and make changes
Change: Updated .gitignore
2026-01-13 10:51:18 -07:00

34 lines
891 B
Go

package main
import (
"fmt"
"os/exec"
"time"
)
func backUp(cmd string, c GoConfig) {
switch cmd {
case "full":
fmt.Println("Starting full server backup")
t := time.Now()
timeStamp := t.Format(time.RFC3339)
fullBackupName := fmt.Sprintf("%s/ServerBackup.%s.tgz", c.Config.BackupDir, timeStamp)
fullBackup := exec.Command("tar", "-czf", fullBackupName, c.Config.ServDir)
err := fullBackup.Run()
if err != nil {
fmt.Printf("Backup Failed: %s\n", err)
}
case "saves":
fmt.Println("Backing up saves")
t := time.Now()
timeStamp := t.Format(time.RFC3339)
savesBackupName := fmt.Sprintf("%s/SaveBackup.%s.tgz", c.Config.BackupDir, timeStamp)
saveDir := fmt.Sprintf("%s/saves", c.Config.ServDir)
savesBackup := exec.Command("tar", "-czf", savesBackupName, saveDir)
err := savesBackup.Run()
if err != nil {
fmt.Printf("Backup Failed: %s\n", err)
}
}
}