I am running this script via a daily cronjob to backup a wordpress site to Amazon S3
* 4 * * * /root/s3backyupsync.sh > /dev/null 2>&1
Contents of .sh script
#!/bin/bash
################################################
# Simple script to synchronise data into S3 bucket(s)
#############################################
LOCALDIR='/var/www/html'
S3BUCKET='s3://my-backup/'
MAILLOG=no
MAILRECEIPIENT=''
MAILSUBJECT='Daily S3 Cloud Backup Sync'
#############################################
### Remember start time
CURRENTDATETIME=$(date +%Y-%m-%-d-%H:%M:%S);
### Sync data
s3cmd --exclude "/wp-content/cache/*" sync --no-progress --recursive --skip-existing --no-check-md5 $LOCALDIR $S3BUCKET;
### Mailing
if [ "${MAILLOG}" = "yes" ]; then
TMPFILE=/tmp/s3backupsynclog.txt;
echo "STARTED: ${CURRENTDATETIME}" > $TMPFILE;
echo "ENDED : $(date +%Y-%m-%-d-%H:%M:%S)" >> $TMPFILE;
echo '' >> $TMPFILE;
s3cmd du -H $S3BUCKET >> $TMPFILE;
echo '' >> $TMPFILE;
rm $TMPFILE;
fi
This however, doesn't update modified files with their new versions.
Also files and folders which no longer exist at the source, are not deleted in Amazon S3.
In general, my script also consumes a lot of resources, so I am wondering if I need to be changing some options here.