Hey all
I'm just trying to make a simple back up script.
I want to move all files and directories that are 1 month old out to back up into a separate folder.
There will be a lot of files and I want to make sure it copies properly.
The problem I'm having is integrating a MD5SUM into it to check integrity. MD5SUM is not recursive, so I figured it would work in a loop when it copies each individual file, I'll do a md5sum on each file and delete that md5 once its verified it copied ok.
I'm pretty bad with the syntax, but I think this is what I want to do.
Code:
#!/bin/sh
for i in find ~/Downloads -mtime +31 | xargs -0 md5sum > md5file.md5
do
cp $i ~/backup
echo "Checking $i"
md5sum -c $i md5file.md5
#on successful hash check, rm $i
done
I think I also need some sort of error handling to output all md5's that didnt pass the hash check.
Inputs?
Thanks.