Backup multiple wordpress sites offsite (without plugin)

Hi All
My first post here but I thought to share a useful bash script I wrote to create offsite backups of multiple wordpress sites on your server to Amazon S3. I wrote this as I was getting frustrated with all these available premium plugins that have issues like bloat or were memory hogs. I decided to skip the wordpress cron system that most of these backup plugins use and wrote a simple bash script using wp-cli and aws-cli. Works like a charm and thought to share with the community.

I love aws cli and its awesome sync command.


This is awesome. Thanks for sharing. You can’t rely on PHP to do this kind of stuff nowadays and a shell or python/perl scripts bypass most PHP limitations. In fact there’s currently no backup plugin that doesn’t time out. One idea we had in the past is to map the uploads directory to some place on Amazon or other cloud service but haven’t really had a chance to find a reliable way to do so.

yes totally. You can sync any folder really. I also prefer only doing /uploads. This was a big pain for us as we manage many client sites on our servers and really could never find a reliable solution. I just love shell scripts.

Feel free to fork and add your own customizations of course :slight_smile:

Thanks for sharing this @ychan!

Thanks for putting this together and sharing it here @ychan !

I think I use a combination of two scripts:

I like how it rotates the backups for daily, weekly, monthly, and yearly. Doesn’t do anything offsite specifically but I set-up a job to connect to my server and sync the backup directory to my local computer so I’ll always have access.

1 Like

I use simple script with daily cron

Then manually upload it to dropbox every few days for the case, I completely lost my server.

I’m using a similar solution to perform backup daily and send email for notification.