• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Jonathan Dingman

Dad, Product Guy, WordPress, SEO, and TailwindCSS.

  • SEO
  • Google
  • Google Sheets
  • WordPress
  • About Jonathan

Jonathan DOT VC » Tech » WordPress Backups to Amazon S3

How to Automate WordPress Backups to Amazon S3 with a Bash Script

February 13, 2020 by Jonathan Dingman Leave a Comment

I’ve been working with WordPress for almost 20 years now. Hosting has always been a pain in my side to properly handle scaling, caching, and delivery. Recently, I started using an Open Source product called WordOps and have been very impressed with it.

The following WordPress backup script is tailored to the file structure of WordOps, but it can easily be customized to fit any need.

To give you some basics of how I adapted this script.

All my sites live in /var/www, such as /var/www/domain.com and furthermore, the main directories live in htdocs. For example, /var/www/domain.com/htdocs which is where WordPress actually lives, with the exception of wp-config.php which lives one level above the web-accessible layer.

Instructions

  1. I first created an IAM user on AWS with full permissions to S3 — only. Nothing else, only S3.
  2. I created a new user on Ubuntu called “wpbak” which is designated only for this task of baking up WordPress.
  3. I enabled sudo access for this user and ensured that sudo could be run without a password.
  4. Lastly, I installed awscli and configured it using this new user that I created in AWS. Make sure you set your zone correctly as well.

Now I can run this script using sudo ./backup.sh and runs just as I expect it to.

Here is the Gist of it.

There are some optional tasks in the script, such as deleting local files, that you can toggle at your pleasure.

HT to Mike at WP Bullet for publishing the previous version. And a huge thanks to ShellCheck.net for bash validation, which helped make it easier to spot errors.

If you have any feedback or suggestions, please do leave them in the comments. I know its far from a perfect script.

Related Posts:

  • accordion-mockup
    How Accordion UX Impacts SEO: Pros, Cons, and Best Practices
  • openx-logo
    OpenX Advanced Targeting Using WordPress
  • schema-org-structured-data-validator
    Leveraging Structured Data Schema.org Markup for…
  • cloudflare-amazon-fail2ban-nginx
    Using Cloudflare, an Amazon Load Balancer, with…

Filed Under: Tech Tagged With: WordOps, WordPress, WordPress Infrastructure

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Jonathan "Jon" Dingman

Welcome to my little corner of the interwebz!

My name is Jonathan.

Recent Posts

  • [Humor] Giving Excel a September 10th rating.
  • Mastering Alphabetization in Google Sheets: A Step-by-Step Guide
  • 100% Free & Simple Full Site Caching at the Edge with Cloudflare
  • Leveraging Structured Data Schema.org Markup for Paginated eCommerce Category Pages
  • How Accordion UX Impacts SEO: Pros, Cons, and Best Practices
  • How to Create a Dropdown List in Google Sheets
  • Sparklines: The Pocket-Sized Warriors of Google Sheets for Quick Data Insights
  • Google Sheets and Data Analysis: Interpreting Zeroes
  • The Ultimate Guide to Dynamic Drop-Down Lists in Google Sheets
  • Google Sheets Best Practices: Perfecting Data Entry with Advanced Validation Techniques
  • Coloring By Numbers in Google Sheets: Making Zeros Disappear
  • 12 Easy to use Features of Google Analytics
  • Self-hosting WordPress: Looking at WordOps vs SlickStack
  • How I Setup a WordPress Cron Job Using AWS Lambda
  • Using Cloudflare, an Amazon Load Balancer, with Nginx and Fail2Ban
  • How to Automate WordPress Backups to Amazon S3 with a Bash Script
  • How to Track Light/Dark Mode in Google Analytics through Google Tag Manager
  • How to Track Ad Block Usage in Google Analytics through Google Tag Manager
  • How to Setup a VAST/VPAID Waterfall with VideoJS
  • How to Return an Empty Cell When the Value is Zero in Google Sheets

Friends

  • Dre is awesome
  • Rareform – Best Upcycled and Recycles Bags

Powered by DigitalOcean
Copyright © 2025

  • Sitemap
  • Privacy
  • Terms