How can I ensure file integrity for copies across multiple external drives?

0
6
Asked By CuriousCat123 On

I'm trying to help out a friend who mirrors files to an external USB hard drive and then syncs that drive to a second USB drive using FreeFileSync. He needs a simple way to confirm that all the copies are accurate. Given that the drives are labeled E: and F:, I thought about using Robocopy to compare the two drives, but it seems Robocopy doesn't handle partial lists of files well since he's not backing up the entire C: drive.

What I came up with is getting the relative paths of files from one external drive, generating hashes for those files on C: and both externals, and then checking if all the hashes match. I'd keep these hashes in a text file that follows a format like this:
hash1 file1
hash2 file2
...

I already have PowerShell commands to generate these hashes on the drives. My plan is to use the following approach:
1. Get hashes of all files from an external drive.
2. List all the files and their relative paths.
3. Compare the hashes generated from both drives.

I've mapped out quite a bit of this in PowerShell code, but I'd love to know if I'm on the right track or if there's a simpler way to achieve this, like using xcopy or something else. Any suggestions?

4 Answers

Answered By HashMaster3000 On

Just a heads up, SMB on Windows actually checks file integrity during file transfer, so you might not need to verify manually. You can also improve your code by using a dictionary for hash comparisons instead of sorting, which speeds up lookup times significantly.

DataSleuth45 -

That's super helpful to know! I tend to overthink file sorting like I did with Unix systems. Sounds like I should trust the protocols a bit more!

Answered By PowerScripter88 On

You're definitely on the right track! Just a tip: when dealing with objects in PowerShell, consider using `Export-Csv` for your hash logs instead of writing plain text files. This way, you can easily import them later while keeping your name and hash information neat and tidy. Also, for your comparison, you could loop through your hash list and check if the hashes match rather than manually fetching them by file paths every time.

BackupBuddy22 -

Thanks for your insight! I'll definitely think about switching to `Export-Csv`. Your suggestion about looping through hashes is solid, too. I might also suggest using `xcopy` for the initial backup, just to be safe and provide a bit of extra protection!

Answered By ShellManiac On

Instead of a hashing solution, have you considered using xcopy with the `/s`, `/v`, and `/e` flags? It can handle a lot of the verification for you during the copy process, and it's quite reliable for ensuring file integrity.

FileGuardian77 -

Great idea! I'm all for being extra cautious, maybe even throwing in QuickPar or MultiPar as an option to further protect against data corruption. They're pretty well-tested.

Answered By RoboGeek99 On

Have you thought about using Rsync? It's a powerful tool for this kind of task, and it efficiently checks file integrity. The only draw is that it might require installing additional software if your friend isn't already set up with it.

EagerHelper56 -

I thought of Rsync too! But the user doesn’t want to install any third-party programs. It’s funny how I’m the third party in this situation!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.