Procházet zdrojové kódy

Updated backup drive data structure

TC pushbot 5 před 4 roky
rodič
revize
6ae0d520d5

+ 4 - 4
mod/filesystem/filesystem.go

@@ -109,10 +109,10 @@ func NewFileSystemHandler(option FileSystemOption) (*FileSystemHandler, error) {
 		if option.Hierarchy == "backup" {
 			//Backup disk. Create an Hierarchy Config for this drive
 			hierarchySpecificConfig = hybridBackup.BackupConfig{
-				DiskUID:          option.Uuid,
-				ParentUID:        option.Parentuid,
-				ParentMountPoint: option.Mountpt,
-				Mode:             option.BackupMode,
+				DiskUID:   option.Uuid,
+				DiskPath:  option.Path,
+				ParentUID: option.Parentuid,
+				Mode:      option.BackupMode,
 			}
 		}
 

+ 0 - 8
mod/filesystem/hybridBackup/datatype.go

@@ -1,8 +0,0 @@
-package hybridBackup
-
-type BackupConfig struct {
-	DiskUID          string //The UID of the target fshandler
-	ParentUID        string //Parent virtual disk UUID
-	ParentMountPoint string //Mount point of the parent disk
-	Mode             string //Backup mode
-}

+ 26 - 2
mod/filesystem/hybridBackup/hybridBackup.go

@@ -1,6 +1,8 @@
 package hybridBackup
 
-import "log"
+import (
+	"log"
+)
 
 /*
 	Hybrid Backup
@@ -20,7 +22,29 @@ import "log"
 
 */
 
+type BackupConfig struct {
+	CycleCounter int64  //The number of backup executed in the background
+	DiskUID      string //The UID of the target fsandlr
+	DiskPath     string //The mount point for the disk
+	ParentUID    string //Parent virtal disk UUID
+	ParentPath   string //Parent disk path
+	Mode         string //Backup mode
+}
+
 func HandleBackupProcess(backupConfig *BackupConfig) (string, error) {
 	log.Println(">>>>>> Running backup process: ", backupConfig)
-	return "Running backup process", nil
+
+	if backupConfig.Mode == "smart" {
+
+	} else if backupConfig.Mode == "nightly" {
+
+	} else if backupConfig.Mode == "append" {
+
+	}
+
+	//Add one to the cycle counter
+	backupConfig.CycleCounter++
+
+	//Return the log information
+	return "", nil
 }

+ 4 - 1
mod/time/scheduler/scheduler.go

@@ -141,7 +141,10 @@ func (a *Scheduler) createTicker(duration time.Duration) chan bool {
 							}
 
 							//Execution suceed. Log the return value
-							cronlog(returnvalue)
+							if len(returnvalue) > 0 {
+								cronlog(returnvalue)
+							}
+
 						} else {
 							//This is requesting to execute a script file
 							scriptFile := thisJob.ScriptFile

+ 22 - 1
storage.go

@@ -9,6 +9,7 @@ import (
 	"runtime"
 
 	"imuslab.com/arozos/mod/filesystem/hybridBackup"
+
 	"imuslab.com/arozos/mod/permission"
 
 	fs "imuslab.com/arozos/mod/filesystem"
@@ -112,9 +113,19 @@ func LoadBaseStoragePool() error {
 func FilesystemDaemonInit() {
 	for _, thisHandler := range fsHandlers {
 		if thisHandler.Hierarchy == "backup" {
-
 			//This is a backup drive. Generate it handler
 			backupConfig := thisHandler.HierarchyConfig.(hybridBackup.BackupConfig)
+
+			//Get its parent mount point for backup
+			parentFileSystemHandler, err := GetFsHandlerByUUID(backupConfig.ParentUID)
+			if err != nil {
+				log.Println("Virtual Root with UUID: " + backupConfig.ParentUID + " not loaded. Unable to start backup process.")
+				break
+			}
+
+			backupConfig.ParentPath = parentFileSystemHandler.Path
+
+			//Create a scheudler for this disk
 			systemScheduler.CreateNewScheduledFunctionJob("backup-daemon ["+thisHandler.UUID+"]",
 				"Backup daemon from "+backupConfig.ParentUID+":/ to "+backupConfig.DiskUID+":/",
 				60,
@@ -188,6 +199,16 @@ func LoadStoragePoolForGroup(pg *permission.PermissionGroup) error {
 	return nil
 }
 
+func GetFsHandlerByUUID(uuid string) (*fs.FileSystemHandler, error) {
+	for _, fsh := range fsHandlers {
+		if fsh.UUID == uuid {
+			return fsh, nil
+		}
+	}
+
+	return nil, errors.New("Filesystem handler with given UUID not found")
+}
+
 func RegisterStorageSettings() {
 	//Storage Pool Configuration
 	registerSetting(settingModule{