Mirror: Only actualization of date/time

Get help for specific problems
Posts: 4
Joined: 25 Jun 2019

pilatus

I moved to another PC and, in the process, copied terabyte-sized files to other NTFS drives. Unfortunately I didn't consider copying the data in such a way that the date remained unchanged. I use date and size as comparison criteria for my FFS-synchronizations, and I now would like to synchronize the source and target mirroring to the same time again without having to synchronize multiple terabytes of data.

As far as I can tell, FFS doesn't have an option to simply synchronize the target date/time with the source during mirror synchronization without copying?

So I would have to perform this process with other software?
User avatar
Posts: 2615
Joined: 22 Aug 2012

Plerry

If you do a Mirror sync, FFS always intends to make the content of your right-side location equal to the content of your left-side location.
So, if the right side contains items with a different timestamp and/or size than its left-side counterpart, FFS will propose to copy the item left-to-right. If you left and right use devices and protocols that allow to retain (file) timestamps when copying, FFS will retain those left-side timestamps when copying left-to-right.

So, you can use FFS for your renewed copying. However, the complete files will be copied over, not just the timestamp updated.
Posts: 1101
Joined: 8 May 2006

therube

Thinking that ROBOCOPY should be able to do it ? might be able to ? similar in the way it can be used to "re-date" changed directory dates.

Do a search here for ROBOCOPY & see if it gives you some ideas.
Posts: 4
Joined: 25 Jun 2019

pilatus

My question was more along the lines of whether FFS might have such a feature (perhaps hidden from me until now).
I had already discovered that Robocopy or similar software could help me. Nevertheless, I would find it useful if FFS also had this feature (just adjusting the timestamp without copying).

I ultimately decided against Robocopy because, after some consideration, I also thought it would be desirable to restore the creation date, not just the modification date. As far as I know, Robocopy can only write the modification date.

That's why I put together a Powershell script with the help of an AI that helped me out when I had problems. I'll post it here; maybe it will be useful to someone else. The configuration placeholders for the source folder, destination folder, and log file in the opening lines must, of course, be defined according to local conditions.
# === CONFIGURATION ===
$sourceDir   = "..."
$targetDir   = "..."
$logFile     = "Log-folder\timestamp-sync-log.txt"

# === LOG START ===
"==== Start: $(Get-Date) ====" | Out-File $logFile

# === PROCESS FILES ===
Get-ChildItem -Path $sourceDir -Recurse -File |
    Sort-Object FullName |
    ForEach-Object {
        # Build relative path and full target path
        $relativePath = $_.FullName.Substring($sourceDir.Length).TrimStart('\')
        $targetFile   = Join-Path $targetDir $relativePath

        $logEntry = "`n[SYNC] File: $relativePath"

        if (Test-Path -LiteralPath $targetFile) {
            try {
                $sourceInfo = Get-Item -LiteralPath $_.FullName
                $targetInfo = Get-Item -LiteralPath $targetFile

                $logEntry += "`n  Source: CreationTime = $($sourceInfo.CreationTime), LastWriteTime = $($sourceInfo.LastWriteTime)"
                $logEntry += "`n  Target: CreationTime = $($targetInfo.CreationTime), LastWriteTime = $($targetInfo.LastWriteTime)"

                # Update timestamps on target file
                Set-ItemProperty -LiteralPath $targetFile -Name CreationTime  -Value $sourceInfo.CreationTime
                Set-ItemProperty -LiteralPath $targetFile -Name LastWriteTime -Value $sourceInfo.LastWriteTime

                # Re-fetch for confirmation
                $targetInfo = Get-Item -LiteralPath $targetFile
                $logEntry += "`n  [OK]    Updated: CreationTime = $($targetInfo.CreationTime), LastWriteTime = $($targetInfo.LastWriteTime)"
            }
            catch {
                $logEntry += "`n  [ERROR] Exception: $_"
            }
        }
        else {
            $logEntry += "`n  [WARN] Target file not found: $targetFile"
        }

        # Output and save log entry
        $logEntry | Tee-Object -FilePath $logFile -Append
    }

# === LOG END ===
"`n==== End: $(Get-Date) ====" | Tee-Object -FilePath $logFile -Encoding UTF8 -Append