#vim mysqlbackupS3.sh #!/bin/bash DB_NAME="faprod" TSTAMP=$(date +"%d-%b-%Y-%H-%M-%S") S3BUCKET="s3://sfo2.digitaloceanspaces.com" #logging LOG_ROOT="./dump.log" #Dump of Mysql Database into S3\ echo "$(tput setaf 2)creating backup of database start at $TSTAMP" >> "$LOG_ROOT" mysqldump --user=root --databases faprod > ./backups/$DB_NAME-$TSTAMP.sql echo "$(tput setaf 3)Finished backup of database and sending it in S3 Bucket at $TSTAMP" >> "$LOG_ROOT" #Delete files older than 15 days find ./backups/* -mtime +15 -exec rm {} \; s3cmd put ./backups s3://name-of-space --recursive echo "$(tput setaf 2)Moved the backup file from local to S3 bucket at $TSTAMP" >> "$LOG_ROOT" echo "$(tput setaf 3)Coll!! Script have been executed successfully at $TSTAMP" >> "$LOG_ROOT"