The regular cp command will print an error message on the standard error file handle and set the $? environment variable to non-0 if an error was encountered while copying.
If you want to keep a log of errors during a large copy, you can re-direct the standard error messages to a file. For example, with this large recursive copy command, we send any error messages to cp_errors, and send a mail containing those errors if there were problems:
Code:
cp -R /var /mnt/backup 2> cp_errors
if [ $? -ne 0 ]; then
cat cp_errors | mailx -s "copy errors" my@email.address
fi
You can also do a similar thing like this, which is a little easier to do from the command line:
Code:
cp -R /var /mnt/backup 2> cp_errors || \
echo "You got errors - see cp_errors"