|
@@ -71,17 +71,22 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
|
|
deletedFileList := map[string]string{}
|
|
deletedFileList := map[string]string{}
|
|
|
|
|
|
//First pass: Check if there are any updated file from source and backup it to backup drive
|
|
//First pass: Check if there are any updated file from source and backup it to backup drive
|
|
|
|
+ log.Println("[HybridBackup] Snapshot Stage 1 - Started " + backupConfig.JobName)
|
|
|
|
+ rootAbs, _ := filepath.Abs(backupConfig.ParentPath)
|
|
|
|
+ rootAbs = filepath.ToSlash(filepath.Clean(rootAbs))
|
|
err = fastWalk(parentRootAbs, func(filename string) error {
|
|
err = fastWalk(parentRootAbs, func(filename string) error {
|
|
if filepath.Ext(filename) == ".db" || filepath.Ext(filename) == ".lock" {
|
|
if filepath.Ext(filename) == ".db" || filepath.Ext(filename) == ".lock" {
|
|
//Reserved filename, skipping
|
|
//Reserved filename, skipping
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if filepath.Ext(filename) == ".datalink" {
|
|
|
|
+ //Reserved filename, skipping
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+
|
|
//Get the target paste location
|
|
//Get the target paste location
|
|
- rootAbs, _ := filepath.Abs(backupConfig.ParentPath)
|
|
|
|
fileAbs, _ := filepath.Abs(filename)
|
|
fileAbs, _ := filepath.Abs(filename)
|
|
-
|
|
|
|
- rootAbs = filepath.ToSlash(filepath.Clean(rootAbs))
|
|
|
|
fileAbs = filepath.ToSlash(filepath.Clean(fileAbs))
|
|
fileAbs = filepath.ToSlash(filepath.Clean(fileAbs))
|
|
|
|
|
|
relPath := strings.ReplaceAll(fileAbs, rootAbs, "")
|
|
relPath := strings.ReplaceAll(fileAbs, rootAbs, "")
|
|
@@ -203,6 +208,7 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
|
|
|
|
|
|
//2nd pass: Check if there are anything exists in the previous backup but no longer exists in the source now
|
|
//2nd pass: Check if there are anything exists in the previous backup but no longer exists in the source now
|
|
//For case where the file is backed up in previous snapshot but now the file has been removed
|
|
//For case where the file is backed up in previous snapshot but now the file has been removed
|
|
|
|
+ log.Println("[HybridBackup] Snapshot Stage 2 - Started " + backupConfig.JobName)
|
|
if previousSnapshotExists {
|
|
if previousSnapshotExists {
|
|
fastWalk(previousSnapshotLocation, func(filename string) error {
|
|
fastWalk(previousSnapshotLocation, func(filename string) error {
|
|
if filepath.Ext(filename) == ".datalink" {
|
|
if filepath.Ext(filename) == ".datalink" {
|
|
@@ -238,8 +244,9 @@ 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
|
|
|
|
|
|
+ //3rd pass: Check if there are anything 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
|
|
//For cases where the backup is applied to overwrite an eariler backup of the same day
|
|
|
|
+ log.Println("[HybridBackup] Snapshot Stage 3 - Started " + backupConfig.JobName)
|
|
fastWalk(snapshotLocation, func(filename string) error {
|
|
fastWalk(snapshotLocation, func(filename string) error {
|
|
if filepath.Ext(filename) == ".db" || filepath.Ext(filename) == ".lock" {
|
|
if filepath.Ext(filename) == ".db" || filepath.Ext(filename) == ".lock" {
|
|
//Reserved filename, skipping
|
|
//Reserved filename, skipping
|
|
@@ -269,12 +276,14 @@ func executeVersionBackup(backupConfig *BackupTask) (string, error) {
|
|
})
|
|
})
|
|
|
|
|
|
//Generate linkfile for this snapshot
|
|
//Generate linkfile for this snapshot
|
|
|
|
+ log.Println("[HybridBackup] Snapshot - Generating Linker File")
|
|
generateLinkFile(snapshotLocation, LinkFileMap{
|
|
generateLinkFile(snapshotLocation, LinkFileMap{
|
|
UnchangedFile: linkedFileList,
|
|
UnchangedFile: linkedFileList,
|
|
DeletedFiles: deletedFileList,
|
|
DeletedFiles: deletedFileList,
|
|
})
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
|
+ log.Println("[HybridBackup] Error! ", err.Error())
|
|
return "", err
|
|
return "", err
|
|
}
|
|
}
|
|
|
|
|