|
@@ -24,6 +24,72 @@ func backup_init() {
|
|
|
router.HandleFunc("/system/backup/listRestorable", backup_listRestorable)
|
|
|
router.HandleFunc("/system/backup/restoreFile", backup_restoreSelected)
|
|
|
router.HandleFunc("/system/backup/snapshotSummary", backup_renderSnapshotSummary)
|
|
|
+ router.HandleFunc("/system/backup/listAll", backup_listAllBackupDisk)
|
|
|
+}
|
|
|
+
|
|
|
+//List all backup disk info
|
|
|
+func backup_listAllBackupDisk(w http.ResponseWriter, r *http.Request) {
|
|
|
+ //Get all fsh from the system
|
|
|
+ runningBackupTasks := []*hybridBackup.BackupTask{}
|
|
|
+
|
|
|
+ //Render base storage pool
|
|
|
+ for _, fsh := range baseStoragePool.Storages {
|
|
|
+ if fsh.Hierarchy == "backup" {
|
|
|
+ task, err := baseStoragePool.HyperBackupManager.GetTaskByBackupDiskID(fsh.UUID)
|
|
|
+ if err != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ runningBackupTasks = append(runningBackupTasks, task)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //Render group storage pool
|
|
|
+ for _, pg := range permissionHandler.PermissionGroups {
|
|
|
+ for _, fsh := range pg.StoragePool.Storages {
|
|
|
+ task, err := pg.StoragePool.HyperBackupManager.GetTaskByBackupDiskID(fsh.UUID)
|
|
|
+ if err != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ runningBackupTasks = append(runningBackupTasks, task)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ type backupDrive struct {
|
|
|
+ DiskUID string //The backup disk UUID
|
|
|
+ DiskName string // The Backup disk name
|
|
|
+ ParentUID string //Parent disk UID
|
|
|
+ ParentName string //Parent disk name
|
|
|
+ BackupMode string //The backup mode of the drive
|
|
|
+ LastBackupCycleTime int64 //Last backup timestamp
|
|
|
+ BackupCycleCount int64 //How many backup cycle has proceeded since the system startup
|
|
|
+ }
|
|
|
+
|
|
|
+ backupDrives := []*backupDrive{}
|
|
|
+ for _, task := range runningBackupTasks {
|
|
|
+ diskFsh, diskErr := GetFsHandlerByUUID(task.DiskUID)
|
|
|
+ parentFsh, parentErr := GetFsHandlerByUUID(task.ParentUID)
|
|
|
+
|
|
|
+ //Check for error in getting FS Handler
|
|
|
+ if diskErr != nil || parentErr != nil {
|
|
|
+ sendErrorResponse(w, "Unable to get backup task info from backup disk: "+task.DiskUID)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ backupDrives = append(backupDrives, &backupDrive{
|
|
|
+ DiskUID: diskFsh.UUID,
|
|
|
+ DiskName: diskFsh.Name,
|
|
|
+ ParentUID: parentFsh.UUID,
|
|
|
+ ParentName: parentFsh.Name,
|
|
|
+ BackupMode: task.Mode,
|
|
|
+ LastBackupCycleTime: task.LastCycleTime,
|
|
|
+ BackupCycleCount: task.CycleCounter,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ js, _ := json.Marshal(backupDrives)
|
|
|
+ sendJSONResponse(w, string(js))
|
|
|
}
|
|
|
|
|
|
//Generate a snapshot summary for vroot
|