Backup Offloaded Amazon S3 Uploads

If you’re using WP Offload S3 to free up local storage then you’ll also need to backup your Amazon S3 uploads. Rather than running two separate backups, one for the website and one for Amazon S3, the following is how I do handle using a single backup bash script.

Rclone can incrementally sync S3 and SFTP

Rclone is amazing. It’s fast, modern, cross platform, scriptable and can sync to and from many cloud providers. Recently they added SFTP support making it perfect for WordPress sites. To get started, download rclone and run rclone config. It will walk you through a wizard to add Amazon S3 and SFTP. For scripting purposes, I use the labeling format of sftp-sitename and s3-sitename.

Store the S3 uploads within the regular WordPress backups

I wanted my website backups to contain a full copy of the web server and S3. I decided to have the backup script create a new folder /wp-content/uploads_from_s3/ which would be only used by Amazon S3 and excluded for the web server backup. Here is a sample of the file .


#   WordPress Backup with S3 Support


# Incremental backup locally with Rclone
rclone sync sftp-$site:${homedir} $localpath/$site/ --exclude .DS_Store --exclude *timthumb.txt --exclude /wp-content/uploads_from_s3/ --verbose=1 --log-file="~/Logs/site-$site.txt"

# Backup S3 uploads if needed
if [ -n "$s3bucket" ]
  rclone sync s3-$site:$s3bucket/$s3path $localpath/$site/wp-content/uploads_from_s3/ --exclude .DS_Store --exclude *timthumb.txt --verbose=1 --log-file="~/Logs/site-$site-s3.txt"