copy if changed
I had written a bunch of versions of something like this for scripts over the years. Had to do it again, yesterday, and decided I’d do it ‘properly’ this time.
It downloads from a url and copies to whatever you specify.
copy_if_changed – copy file from a remote url to local destination. Return 0
if file has changed, 1 if it hasn’t and 2 if an error occurs
usage is: copy_if_changed url /some/local/destination
Really handy in shell scripts:
if copy_if_changed http://server/some/file /etc/some/file; then
- it makes a unique (timestamped) backup of the dest file before it copies it over.
- it uses sha256 for the checksumming
Not sure if it is useful to anyone else but I’m tired of rewriting the same thing.