Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

Verify if files have been copied correctly

Post Reply
User avatar
Forum Regular
Forum Regular
Posts: 295
Joined: Thu Jul 13, 2006 6:35 pm

Verify if files have been copied correctly

#1 Post by outlaw » Sat Apr 28, 2018 10:01 am

I want to copy / transfer files from location to another then verify the files were copied correctly.

One technique to verify if a group of files has been copied correctly to another location would be to:
1) Create a archive of the files ... (tar, cpio or bz - whatever)
2) Create a md5sum for the archive then copy or transfer the archive to the new location.
3) Then create a new md5sum for the archive in the new location.
4) Use diff to compare the 2 md5sum files.

Can cp or another command be used to accomplish this task.
I need to copy all files in the specified directory and sub-directories.

Thanks in advance for any advice / suggestions offered.

Naturally nuts no pharmaceuticals required :happy:

User avatar
Forum Veteran
Forum Veteran
Posts: 8697
Joined: Wed Jul 12, 2006 1:42 am

Re: Verify if files have been copied correctly

#2 Post by Adrian » Sat Apr 28, 2018 10:15 am

rsync checks md5 of the copied files use that, it also gives you nice option to update the copied files without having to copy all the stuff again.

User avatar
Forum Guide
Forum Guide
Posts: 1156
Joined: Wed Apr 11, 2018 5:09 pm

Re: Verify if files have been copied correctly

#3 Post by fehlix » Sat Apr 28, 2018 12:34 pm

If rsync together with md5-checksum does not fit into your file-transfer scenario
an alternative approach would be to recursively create a checksum file of that directory tree
and transfer this checksum file with the transfered files itself.
For checking file transfer success shortly after it took place
md5-checksum might sufficient. But as md5 does have a well-known collusion security-issue
I would not recommend using it for anything else. I.e. if you are going to verify
the checksum long time after the file transfer took place a better approach migth be to use sha256.
To use the more collusion-robust sha256 in combination with creating a hashsum tree
here en axample:

Code: Select all

# to get recursive hashsum-tool hashtree
# sudo apt-get install hashtree
# my source dir
cd $DIR
sha256deep -lr . | tee $DIR.sha256
# to verify after transfer use
echo "sha256sum -c $DIR.sha256"
Happy hashing :happy:

Post Reply

Return to “Desktop Environment”