0

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.

Harrys Kavan
  • 402
  • 1
  • 5
  • 19

3 Answers3

3

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.

Stone
  • 7,011
  • 1
  • 21
  • 33
  • 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: https://lwn.net/Articles/139923/ – Dr. Edward Morbius Jul 25 '12 at 23:49
2

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.

MadHatter
  • 79,770
  • 20
  • 184
  • 232
  • 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 :) – Harrys Kavan Jul 20 '12 at 11:20
2

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.

BillThor
  • 27,737
  • 3
  • 37
  • 69