|
@@ -20,22 +20,27 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
|
|
|
//Check if the backup parent root is identical / within backup disk
|
|
|
parentRootAbs, err := filepath.Abs(backupConfig.ParentPath)
|
|
|
if err != nil {
|
|
|
+ backupConfig.PanicStopped = true
|
|
|
return "", errors.New("Unable to resolve parent disk path")
|
|
|
}
|
|
|
|
|
|
backupRootAbs, err := filepath.Abs(filepath.Join(backupConfig.DiskPath, "/version/"))
|
|
|
if err != nil {
|
|
|
+ backupConfig.PanicStopped = true
|
|
|
return "", errors.New("Unable to resolve backup disk path")
|
|
|
}
|
|
|
|
|
|
if len(parentRootAbs) >= len(backupRootAbs) {
|
|
|
if parentRootAbs[:len(backupRootAbs)] == backupRootAbs {
|
|
|
//parent root is within backup root. Raise configuration error
|
|
|
- log.Println("*HyperBackup* Invalid backup cycle: Parent drive is located inside backup drive")
|
|
|
+ log.Println("[HyperBackup] Invalid backup cycle: Parent drive is located inside backup drive")
|
|
|
+ backupConfig.PanicStopped = true
|
|
|
return "", errors.New("Configuration Error. Skipping backup cycle.")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ backupConfig.PanicStopped = false
|
|
|
+
|
|
|
todayFolderName := time.Now().Format("2006-01-02")
|
|
|
previousSnapshotExists := true
|
|
|
previousSnapshotName, err := getPreviousSnapshotName(backupConfig, todayFolderName)
|
|
@@ -65,7 +70,7 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
|
|
|
|
|
|
//First pass: Check if there are any updated file from source and backup it to backup drive
|
|
|
fastWalk(parentRootAbs, func(filename string) error {
|
|
|
- if filepath.Base(filename) == "aofs.db" || filepath.Base(filename) == "aofs.db.lock" {
|
|
|
+ if filepath.Ext(filename) == ".db" || filepath.Ext(filename) == ".lock" {
|
|
|
//Reserved filename, skipping
|
|
|
return nil
|
|
|
}
|
|
@@ -184,7 +189,7 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
|
|
|
//For case where the file is backed up in previous snapshot but now the file has been removed
|
|
|
if previousSnapshotExists {
|
|
|
fastWalk(previousSnapshotLocation, func(filename string) error {
|
|
|
- if filepath.Base(filename) == "snapshot.datalink" {
|
|
|
+ if filepath.Ext(filename) == ".datalink" {
|
|
|
//System reserved file. Skip this
|
|
|
return nil
|
|
|
}
|
|
@@ -221,7 +226,7 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
|
|
|
//3rd pass: Check if there are anything (except file with .deleted) in today backup drive that didn't exists in the source drive
|
|
|
//For cases where the backup is applied to overwrite an eariler backup of the same day
|
|
|
fastWalk(snapshotLocation, func(filename string) error {
|
|
|
- if filepath.Base(filename) == "aofs.db" || filepath.Base(filename) == "aofs.db.lock" {
|
|
|
+ if filepath.Ext(filename) == ".db" || filepath.Ext(filename) == ".lock" {
|
|
|
//Reserved filename, skipping
|
|
|
return nil
|
|
|
}
|