Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do i figure out if there's a difference between an backupfile and the current used one.
The Filename of the Backup is named like: filename_date.conf
and the currend used one is name like: filename.conf
I only need to know if the content is the same or not!

I know how to copy the files and rename it like i wish, but i don't know how to figure out if there's a content difference.

share|improve this question
    
You could write a script which compare files by the SHA1 checksum. –  golja Jul 20 '12 at 10:40
add comment

3 Answers 3

up vote 3 down vote accepted

Use md5sum.

You can md5 remote files though ssh, like

ssh user@host md5sum filename_date.conf

then you can md5sum the local file and compare those.

share|improve this answer
    
thank you very much, work's like a charme :D –  zwarag Jul 20 '12 at 11:19
    
NB: sha1 is more robust, particularly if you're concerned about intentional md5 collisions. Which are now pretty easy to engineer, if your process is open to external influence: lwn.net/Articles/139923 –  Dr. Edward Morbius Jul 25 '12 at 23:49
add comment

There's nothing wrong with Stone's excellent answer (+1!), but since you ask about rsync, you might want to investigate the -c flag, which tells rsync to perform a checksum (MD4, as it happens) to assist in deciding if a file has been modified, before deciding whether or not to transfer it.

share|improve this answer
    
thank you too, i'd have to use scp because with this date in the filename it i wouldn't be able to automize it with rsync. Maybe i'll try this after vacation :) –  zwarag Jul 20 '12 at 11:20
add comment

rsync already has a lot of mechanisms to check for differences. If you aren't renaming files rsync won't transfer unchanged files.

I have used rsync to minimize transfer for open log files by only transferring the new data. The man documentation discusses your various options.

Tools like backuppc and Unison use the rsync protocol and capabilities to minimized data transfer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.