Hello I have a quick question. I am trying to implement a differential backup but where I am having trouble is comparing the hash from md5sum.txt to diffmd5.txt
I am getting the following error:
Currently the command runs and gives no errors but files are not being replaced and not backing up any files
#!/bin/bash
bkdest="/home/user/backup/differential/backup_diff"
bksource="/home/user/Documents"
destgen=`find $bkdest/* -exec md5sum {} + > diffmd5.txt`
sourcegen=`find $bksource/* -exec md5sum {} + > md5sum.txt`
$sourcegen
$destgen
$(cat diffmd5.txt) | while read f;
do
if [ $(grep f md5sum.txt | wc -l) -lt 1 ]
then
# Code to backup the file that has changed or is not on record
cp $(cut -d ' ' -f2-- <<< $f) $bkdest
fi
done
# Afterwards, update md5hashes to list newly backed up files
$sourcegen
Please help me out on figuring out where I went wrong. Thank you!
Guess this is my error when running in debug mode
Try 'cp --help' for more information.
grep: md5sum.txt: No such file or directory
cut: invalid byte, character or field list
Try 'cut --help' for more information.
cp: missing destination file operand after ‘/home/dmitriy/backup/differential/backup_diff’