1 Backgroud
I use FreeFileSync to mirror my internal hard drive's file to external hard drive. And I find out if I set "Delete files" option to "Permanent", when FreeFileSync is mirroring file, it will first delete target's orphan file, then copy source file into target. For Data Safety, I need the data copies >= 2 at any time (Or why should I do backup at all, right?). Due to this behavior, when FreeFileSync is syncing file, the target folder's data will not be complete. If the source drive is broken during the process, I will not be able to recover even old version from the mirror.
I have a 4T external hard drive for backup, sometimes I modify or move a large amount of files inside internal drive, so it spends hours to copy all the modified data. It worries me that in this few hours, my mirrored backup is simply incomplete.
Yes, I can use Versioning to keep all the old versions. But I use windows file history to do versioned backup, and use FreeFileSync to do mirror backup. I hope the mirrored version simply be 1.
2 What Behavior Do I Expect
In the "Delete files" Options, add an additional "Safe Atomic Permanent" option. When selected this option, all deleted and modifed files will be moved to a seperate versioned folder, after and only after one successful mirror, the versioned folder will be deleted.
3 My Homebrew Solution - Overview
Since Now FreeFileSync do not have the above option, I use custom config & commandline to do the same thing. I think this might help others, so I decided to post it here.
Tested FreeFileSync version: 11.17
Tested Operating System: Windows 10
Test Setup: Copy file from internal hard drive to external hard drive. I haven't tested any other connection method like sftp.
Test Result: Both modified and deleted file will be moved to the version folder, so old version will be safe while mirroring.
Test Result: Both modified and deleted file will be moved to the version folder during mirroring, after and only after a successful mirror, old version will be automatically deleted.
4 My Homebrew Solution - Config FreeFileSync
(1) source & target should use volume label
source directory: `[TestData]\source\atomic mirror`
target directory: `[TestData]\target\atomic mirror`
(2) Move files to a user-defined folder
[TestData]\Revisions-freefilesync\atomic mirror
Use "Time stamp [Folder]". Every failed sync's file will be located in a seperate directory, so there will be no confliction, so old version file will be safe.
(4) Limit file versions
Do not limit it! On successive failures, you will not want your original version of mirrored file being deleted. On successful sync, the command will delete all old versions.
(5) Run a command - On Success
Make sure select "On success:". Do not use on completion, completion include success and failure, you'll only want to delete old version on success, rather than some failures like disk failure or anything break your sync process.
(6) Run a command - the command
The command will remove the version directory only after a successful sync.
(6.1) internal drive only
You can use fixed drive letter
rmdir /s /q "E:\Revisions-freefilesync\atomic mirror"
Windows May change the drive letter when you reconnect the removable storage, so you cannot use drive letter.
I tried use volume label, it's not working.
rmdir /s /q "[TestData]\Revisions-freefilesync\atomic mirror"
1. First find you drive's GUID. You can get volume GUID and driver letter mapping info by execute following command in cmd (do not require admin rights)
mountvol.exe
rmdir /s /q "\\?\Volume{576f2736-1404-46b6-b46e-cf34cc7260f0}\Revisions-freefilesync\atomic mirror"