SystemFiles/backuply

BUG: Missing some changes and file deletions

Closed this issue · 4 comments

I suspect this is files added from full backup to the set of files in merged record before differential are added to the fileSet but this does not override the fileData already in the set with the changed.

The deleted files are added in the earlier _mergeBackups method and take the file that existed in full backup and the file is then not removed when checking differential backup's file list.

Below is the output for the ending merged fileSet

Set(9) {
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-full-2021-06-20/abc/dce/f6',
    byteLength: 7,
    md5sum: '8977dfac2f8e04cb96e66882235f5aba',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-full-2021-06-20/abc/f3',
    byteLength: 0,
    md5sum: 'd41d8cd98f00b204e9800998ecf8427e',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-full-2021-06-20/abc/f4',
    byteLength: 7,
    md5sum: '8977dfac2f8e04cb96e66882235f5aba',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-full-2021-06-20/f1',
    byteLength: 0,
    md5sum: 'd41d8cd98f00b204e9800998ecf8427e',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-full-2021-06-20/f2',
    byteLength: 0,
    md5sum: 'd41d8cd98f00b204e9800998ecf8427e',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-full-2021-06-20/single/single.txt',
    byteLength: 0,
    md5sum: 'd41d8cd98f00b204e9800998ecf8427e',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-diff-2021-06-20/abc/dce/f6',
    byteLength: 14,
    md5sum: 'cd31be3a2a60b39f2f1e52decd78ab95',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-diff-2021-06-20/abc/f4',
    byteLength: 14,
    md5sum: 'cd31be3a2a60b39f2f1e52decd78ab95',
    deleted: false
  },
  {
    fullPath: '/Users/bensykes/Documents/GitHub Projects/backuply/dev/backup_dest/test-backup-diff-2021-06-20/single/single.txt',
    byteLength: 15,
    md5sum: 'f573c260c18ec17d95ac48baff76db9a',
    deleted: false
  }
}

Notice f2 exists from test-backup-full even though it is deleted in test-backup-diff

Also notice that there are duplicates of f4 since they can not be identified as unique so the set allows them to be added and then it all depends on how the copy function eventually copies the files (the order I mean) whether or not the newest version of the file is copied.

This code is based on e866c59 and master should likely be reverted back to this commit since other issues may now exist in the newest version.

Files marked deleted are not being deleted... that is the main point here.

Seems to be resolved mostly:

// Add all non-deleted files (unique) - Should also automatically account for files in deleted dirs
for (const ff of fullBackup.fileList) {
  ff.fullPath = await this._updatePathRoot(ff.fullPath, fullBackup.sourceRoot, fullBackup.destRoot)
  const fbRelPath = ff.fullPath.split(fullBackup.name).reverse()[0]
  
  // Add each file from full backup (we will make adjustments next for modified or deleted files)
  fileSet.add(ff)
  
  // Validate against files in the differential backup (and make modifications/replacements as necessary)
  for (const df of diffBackup.fileList) {
	  df.fullPath = await this._updatePathRoot(df.fullPath, diffBackup.sourceRoot, diffBackup.destRoot)
	  const dbRelPath = df.fullPath.split(diffBackup.name).reverse()[0]
	  
	  if (fbRelPath === dbRelPath) {
		  // File Deleted
		  if (df.deleted) fileSet.delete(ff)
  
		  // File Modified
		  if (df.md5sum !== ff.md5sum) {
			  fileSet.delete(ff)
			  fileSet.add(df)
		  }
	  }
	  // File Added
	  fileSet.add(df)
  }
}