Write a script to automate the backup of a directory to an AWS S3 bucket, including basic error handling.