Compare Checksum of Files Between Two Servers and Report Mismatch

compare checksum of files between two remote servers

I think it has to do with multiple path from machineA included in the filename processed over in machineB... the following command isn't pretty but worked for me, hope it helps.

find /primary/ /secondary/ -type f | xargs md5sum | awk -F'/' '{print "echo "$1 $NF " | ssh user@machineB \"(cd /bat/snap/  && md5sum -c)\""}' | bash

Database Design For reporting comparison results

I would say neither of your two options (additional column, or new table) are optimal. I think this would be best handled with a view. Something like:

CREATE VIEW MisMatches
AS
SELECT Material_ID = ISNULL(a.Material_ID, b.Material_ID),
Status = CASE WHEN a.Material_ID IS NULL THEN 'Mising A'
WHEN b.Material_ID IS NULL THEN 'Mising B'
WHEN a.Material_Name <> b.Material_Name THEN 'Mismatch Name'
WHEN a.Material_Type <> b.Material_Type THEN 'Mismatch Type'
WHEN a.Quantity <> b.Quantity THEN 'Mismatch Quantity'
END,
MaterialName_A = a.Material_Name,
MaterialName_B = b.Material_Name,
Material_Type_A = a.Material_Type,
Material_Type_B = b.Material_Type,
Quantity_A = a.Quantity,
Quantity_B = b.Quantity
FROM A_Data AS a
FULL JOIN B_Data AS b
ON b.Material_ID = a.Material_ID
WHERE CHECKSUM(a.Material_Name, a.Material_Type, a.Quantity) <> CHECKSUM(b.Material_Name, b.Material_Type, b.Quantity);

This short circuits on your status column which may not be what you want, that is to say that if you name, quantity and type all don't match, then the status will only tell you that the name is a mismatch. If you want all mis-matches you will need to extend the case expression slightly. Also, if any of your columns are nullable, you will need to handle this in the Status case expression, e.g.

WHEN a.Quantity <> b.Quantity OR a.Quantity IS NULL OR b.Quantity IS NULL THEN ...

I have also had to make an assumption about how you identify a match, but hopefully this gives the general gist of it

Edit

There is a better way of doing this rather than CHECKSUM:

CREATE VIEW MisMatches
AS
SELECT Material_ID = ISNULL(a.Material_ID, b.Material_ID),
Status = CASE WHEN a.Material_ID IS NULL THEN 'Mising A'
WHEN b.Material_ID IS NULL THEN 'Mising B'
WHEN a.Material_Name <> b.Material_Name THEN 'Mismatch Name'
WHEN a.Material_Type <> b.Material_Type THEN 'Mismatch Type'
WHEN a.Quantity <> b.Quantity THEN 'Mismatch Quantity'
END,
MaterialName_A = a.Material_Name,
MaterialName_B = b.Material_Name,
Material_Type_A = a.Material_Type,
Material_Type_B = b.Material_Type,
Quantity_A = a.Quantity,
Quantity_B = b.Quantity
FROM A_Data AS a
FULL JOIN B_Data AS b
ON b.Material_ID = a.Material_ID
WHERE NOT EXISTS
( SELECT a.Material_Name, a.Material_Type, a.Quantity
INTERSECT
SELECT b.Material_Name, b.Material_Type, b.Quantity
);

I discovered this read the following article: Undocumented Query Plans: Equality Comparisons

How to compare binary files to check if they are the same?

The standard unix diff will show if the files are the same or not:

[me@host ~]$ diff 1.bin 2.bin
Binary files 1.bin and 2.bin differ

If there is no output from the command, it means that the files have no differences.



Related Topics



Leave a reply



Submit