MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / ThreadfinAutoBackup

Function ThreadfinAutoBackup

src/backup.go:13–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11)
12
13func ThreadfinAutoBackup() (err error) {
14
15 var archiv = "threadfin_auto_backup_" + time.Now().Format("20060102_1504") + ".zip"
16 var target string
17 var sourceFiles = make([]string, 0)
18 var oldBackupFiles = make([]string, 0)
19 var debug string
20
21 if len(Settings.BackupPath) > 0 {
22 System.Folder.Backup = Settings.BackupPath
23 }
24
25 showInfo("Backup Path:" + System.Folder.Backup)
26
27 err = checkFolder(System.Folder.Backup)
28 if err != nil {
29 ShowError(err, 1070)
30 return
31 }
32
33 // Alte Backups löschen
34 files, err := os.ReadDir(System.Folder.Backup)
35
36 if err == nil {
37
38 for _, file := range files {
39
40 if filepath.Ext(file.Name()) == ".zip" && strings.Contains(file.Name(), "threadfin_auto_backup") {
41 oldBackupFiles = append(oldBackupFiles, file.Name())
42 }
43
44 }
45
46 // Alle Backups löschen
47 var end int
48 switch Settings.BackupKeep {
49 case 0:
50 end = 0
51 default:
52 end = Settings.BackupKeep - 1
53 }
54
55 for i := 0; i < len(oldBackupFiles)-end; i++ {
56
57 os.RemoveAll(System.Folder.Backup + oldBackupFiles[i])
58 debug = fmt.Sprintf("Delete backup file:%s", oldBackupFiles[i])
59 showDebug(debug, 1)
60
61 }
62
63 if Settings.BackupKeep == 0 {
64 return
65 }
66
67 } else {
68
69 return
70

Callers 2

maintenanceFunction · 0.85
StartSystemFunction · 0.85

Calls 5

showInfoFunction · 0.85
checkFolderFunction · 0.85
ShowErrorFunction · 0.85
showDebugFunction · 0.85
zipFilesFunction · 0.85

Tested by

no test coverage detected