Score:3

Best way to backup a WordPress site on EC2 instance

jp flag

My WordPress site is sitting on a single EC2 instance. My site has 60GB worth of files and a 800MB database size. My site is running out of space just by running the Duplicator plugin to back it up. What would be your recommended alternative? EBS snapshot? AMI? etc?

UPDATE: I'd like to keep the backup files remotely.

sv flag
Welcome to ServerFault. Recommendations vary based on opinions that may lead to different answers. So, please narrow-down your question. That said, why would you want to keep backups locally? Ideally, they should go offsite, such as to AWS S3 where you can delete them periodically using life-cycle policies.
jp flag
@PothiKalimuthu Thanks for pointing that out. I've updated my question to reflect the desire to keep backup files remotely. Also, I'm assuming AMI and EBS are considered offsite?
sv flag
While the question is already answered by Tim and it has already been selected as the right answer, let me share my thoughts on backups as an answer too, as it will better visibility for others.
Score:2
gp flag
Tim

EBS Snapshots are essential. They give you a quick way to restore your instance to a known good state if something happens to it. I suggest using Lifecycle Manager in the AWS EC2 console, you could take snapshots nightly or weekly and keep them for as long as you think necessary, depending on your RPO / recovery point objective. Note that EBS snapshot costs start to add up quickly, even though they're meant to deduplicate blocks across your snapshots.

An AMI is just an EBS snapshot with a bit of metadata about your instance. No real need.

For an offsite backup what I do is:

  • Run a MySqlDump every night
  • Run the open source Restic backup tool configured to store MySQL backups and the Wordpress files to an offsite location each night. You can have the repo on B2, S3, Azure, Google, etc, details here.

An essential part of backups is doing regular restore tests.

Score:0
cn flag

Tim mentions EBS snapshots which are great. But I prefer AMI images. Why?

  1. Restoring a fresh EC2 instance is fewer steps than trying to create a fresh EC2 instance from EBS snapshots only.
  2. You get EBS snapshots along with your AMI image anyways.
  3. There is no extra cost of an AMI image compared to EBS snapshots.

Note: It is possible to create AMI images from EBS snapshots, but this does not work for Windows AMI images.

Score:0
sv flag

While the question is already answered by Tim and it has already been selected as the right answer, let me share my thoughts on backups as an answer too, as it will have better visibility for others. As mentioned in my comment to the original question, the question is very broad. It can lead to multiple answers. There are different types of backups. For example, what Tim answered was for server-level backups where the entire server is taken as a backup. It happens irrespective of the app or software it runs (such as WordPress).

App-level backups can also be taken. Depending on the app, some apps have only static files. Some have databases. For WordPress, it contains both DB and files. App-level backups are independent of servers that they run on. When we have app-level backups, we can quickly switch the host. Most hosted WordPress platforms offers free migration. All they'd require is a complete WordPress backup (of DB and files). So, when we have a complete WP backup, we can host our site on any webhost (not just AWS EC2). Another advantage of app-level backups is... it is even possible to automate the process of deploying our site or we can quickly deploy a staging site from the backups to test drive the updates (such as WordPress core updates, themes and plugins).

Since both WordPress and Duplicator plugin are mentioned, I thought you were looking for app-level backup solution. EBS snapshot does work great on certain use-cases. There is no particular solution that fits every use-case. For example, some sites may require real-time backup of DB and / or files. In such cases, something similar to VaultPress is the recommended solution.

Tim avatar
gp flag
Tim
EBS snapshots are for server level backups, but I also described application level backups.
sv flag
Agreed. Actually, after seeing yours, I am going to give restic another try. Abandoned it long ago. Thanks for the heads up.
Tim avatar
gp flag
Tim
I've been using Restic for a few years at least, it's always been reliable for me, and it's under steady active development. I do restore tests every six months, so far so good.
Score:0
cn flag

(1) Enable snapshots. It won't be needed for any backup app, but you'll have some consistency and recovery points.

(2) After enabling snapshots in (1), You can configure your backup plugin (JetPack, BlogVault etc, WordPress has a few options) or even a simple bash script executed on timely manner after snapshot it taken to directly upload the up-to-date files to S3 (S3 has Linux CLI so it won't be super-difficult) outside of your running VM. This way, the backup files won't consume space on your EC2 instance.

(3) If you don't want to mess with (1) and (2) you can use commercial backup application like Veeam available on AWS platform.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.