How to Set Up Automatic Backups for Your Website or App
November 18, 2026 · 9 min read

Every website and app will eventually face a bad day: a failed update, a deleted database table, a hacked plugin, a hosting outage or a ransomware attack. When that day comes, the only thing that matters is whether you can get your data back quickly. That is why automatic backups are one of the most valuable and most neglected parts of running any online business.
This guide shows you how to set up automatic backups for a website or app the right way. You will learn what to back up, how often, where to store copies, how to protect backups from ransomware, and how to test that restores actually work. We also include a ready-to-use backup script for a database-driven web app.
Why Automatic Backups Matter
Manual backups fail because people forget, go on holiday or assume someone else did it. Automatic backups run on a schedule without anyone remembering, and they are your last line of defence when everything else goes wrong.
The risks are real. Verizon's 2026 Data Breach Investigations Report found ransomware in 48% of breaches it analysed, as TechRepublic reported. Sophos's State of Ransomware 2026 report put the average cost of recovering from a ransomware attack at $1.7 million, excluding any ransom, according to Sophos. Reliable, tested backups are what allow a business to recover without paying criminals. Our ransomware protection guide covers the wider defence plan.
What Should You Back Up?
- Databases: customer records, orders, content and settings. This is usually your most valuable data.
- Uploaded files: images, documents and media uploaded by staff or users.
- Application code: stored in a Git repository with a remote copy, plus build configuration.
- Configuration: server settings, environment configuration and infrastructure definitions. Store secrets in a secrets manager rather than in plain backup files.
- Third-party data: exports from key SaaS tools, email and DNS records.
The 3-2-1 Backup Rule
The most widely recommended backup strategy is the 3-2-1 rule: keep three copies of your data, on two different types of storage, with one copy offsite, as the California Privacy Protection Agency explains. For example, your live database, a nightly backup on a separate storage service and a copy in a different cloud region or provider.
Many organisations now extend this to 3-2-1-1-0: one copy that is immutable or offline so it cannot be altered or deleted, and zero errors when you test a restore.
Key Terms: RPO and RTO
Two numbers define your backup plan:
- Recovery point objective (RPO): how much data you can afford to lose, measured in time. A daily backup means you could lose up to 24 hours of data. See NIST's definition of the recovery point objective.
- Recovery time objective (RTO): how quickly you must be back online after an incident. See NIST's definition of the recovery time objective.
An online shop taking orders all day may need an RPO of minutes and an RTO of an hour, while a brochure website can tolerate a daily backup and a longer recovery time.
How Often Should You Back Up?
| Type of Site or App | Suggested Frequency | Suggested Retention |
|---|---|---|
| Brochure website, rarely updated | Weekly, plus before every update | 1 to 3 months |
| Blog or content site | Daily | 30 days |
| E-commerce store | Hourly or continuous database backups, daily files | 30 to 90 days |
| SaaS product or mobile app backend | Continuous point-in-time recovery plus daily snapshots | 30 days or more, depending on contracts |
| Regulated data such as health or finance | Continuous | As required by law and policy |
These are starting points. Agree your RPO and RTO with the business, then set frequency and retention to match.
How to Set Up Automatic Backups by Platform
WordPress and other CMS websites
Start with your hosting provider's backup features, then add an independent plugin that sends copies to separate storage. UpdraftPlus is a popular option that schedules file and database backups to cloud storage such as Amazon S3, Google Drive or Dropbox. Keep at least one copy outside your hosting account. Our comparison of WordPress vs a custom website covers other maintenance differences.
Custom web apps on your own server
Schedule database dumps and file backups with a script and cron job, as in the example below, and copy them to storage outside the server. For file-level backups with encryption and deduplication, tools such as restic work well.
Managed cloud databases and services
Managed databases on AWS, Azure and Google Cloud offer automated backups and point-in-time recovery. Turn them on, set the retention period, and copy snapshots to a second region or account. AWS Backup can manage backup policies across many services from one place.
Backend platforms such as Firebase and Supabase
Check exactly what your plan includes. Some free tiers do not include automatic backups, and point-in-time recovery is often a paid feature. Schedule your own exports to separate storage for critical data.
Mobile apps
For mobile apps, the important data lives in the backend, so back up the server database, file storage and user accounts. Also keep signing keys, certificates and store configuration safely backed up, because losing them can block future app updates.
Example: An Automated Database Backup Script
This Bash script creates a compressed, consistent backup of a MySQL database using mysqldump, copies it to Amazon S3 and deletes local copies older than 14 days:
#!/usr/bin/env bash
# backup.sh: nightly MySQL backup copied to Amazon S3, with 14 days of local copies
set -euo pipefail
DB_NAME="shop"
BACKUP_DIR="/var/backups/mysql"
S3_BUCKET="s3://example-company-backups/mysql"
TIMESTAMP="$(date +%Y-%m-%d_%H%M)"
FILE="${BACKUP_DIR}/${DB_NAME}_${TIMESTAMP}.sql.gz"
mkdir -p "$BACKUP_DIR"
# Database credentials come from ~/.my.cnf, never from this script
mysqldump --single-transaction --routines --triggers "$DB_NAME" | gzip > "$FILE"
# Copy the backup off the server
aws s3 cp "$FILE" "$S3_BUCKET/" --storage-class STANDARD_IA
# Keep 14 days of local copies
find "$BACKUP_DIR" -name "${DB_NAME}_*.sql.gz" -mtime +14 -delete
echo "Backup completed: $FILE"
Schedule it with cron to run every night:
# Run the backup every night at 02:30 and log the output
30 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
For production use, enable versioning and object lock on the storage bucket so backups cannot be overwritten or deleted, give the backup job credentials that can only upload, and send an alert if a backup fails or does not run.
Protect Your Backups from Ransomware
Modern ransomware groups look for backups and try to delete or encrypt them before launching an attack. Protect them by:
- Keeping at least one copy offline or immutable, using object lock or write-once storage
- Using separate credentials and accounts for backups, protected by multi-factor authentication
- Encrypting backups at rest and in transit
- Restricting who can delete backups or change retention settings
- Monitoring for unusual deletion activity
The CISA #StopRansomware Guide recommends maintaining offline, encrypted backups of critical data and regularly testing their availability and integrity.
Test Your Restores
A backup you have never restored is only a hope. Schedule restore tests at least quarterly, and after major changes:
- Restore the latest backup to a separate test environment.
- Check that the application starts and that recent data is present.
- Measure how long the restore took and compare it with your RTO.
- Document the steps so anyone on the team can follow them under pressure.
- Fix any gaps you find and test again.
Backup Options Compared
| Option | Best For | Watch Out For |
|---|---|---|
| Hosting provider backups | Quick recovery from small mistakes | Same account as the live site; short retention |
| CMS backup plugins | WordPress and similar sites | Plugin must be kept updated and monitored |
| Managed database backups | Cloud databases with point-in-time recovery | Copies may stay in one region unless you replicate them |
| Scripts and cron jobs | Custom apps on your own servers | Needs monitoring and alerts when jobs fail |
| Cloud backup services | Central policies across many systems | Costs grow with retention and data volume |
Your Backup Setup Checklist
- RPO and RTO agreed for each system
- Databases, files and configuration all included
- Backups run automatically on a schedule
- At least one copy stored in a separate account or region
- One copy immutable or offline
- Backups encrypted and access restricted
- Alerts for failed or missing backups
- Restore tested in the last three months and documented
Common Backup Mistakes
- Storing backups on the same server or account as the live site
- Backing up files but forgetting the database, or the reverse
- Never testing restores until an emergency
- No alerts when a scheduled backup fails
- Keeping backups forever, which increases cost and privacy risk
- Including passwords and secrets in unencrypted backup files
Backups are one of the core basics in our guides to cybersecurity for small business and how to protect your website from hackers. If you are moving systems, verify backups before any cloud migration.
Frequently Asked Questions
How often should I back up my website?
Back up at least daily for most business websites, and before every update. E-commerce stores and apps that change constantly should use hourly or continuous database backups.
Are my hosting provider's backups enough?
Not on their own. Provider backups are useful, but they are usually stored in the same account and may have short retention. Keep at least one independent copy elsewhere.
What is the 3-2-1 backup rule?
Keep three copies of your data, on two different types of storage, with one copy stored offsite. Many businesses add an immutable or offline copy for ransomware protection.
How long should I keep backups?
Thirty to ninety days suits most businesses, with longer retention for monthly or yearly copies where needed. Follow any legal or contractual requirements, and do not keep personal data longer than necessary.
Can backups protect against ransomware?
Yes, if at least one copy is offline or immutable and you have tested restores. Attackers often target backups, so separate credentials and write-once storage are essential.
How much do automatic backups cost?
For most small and medium websites, backup storage costs a few dollars to a few tens of dollars a month. That is tiny compared with the cost of losing your data or your customers' trust.
Conclusion
Automatic backups are cheap insurance against expensive disasters. Decide your RPO and RTO, back up databases, files and configuration on a schedule, follow the 3-2-1 rule, protect at least one copy from ransomware and test your restores regularly. Set it up once, monitor it, and you will be ready when something goes wrong. Ongoing backups are also part of realistic app maintenance costs, so budget for them from the start.
Want backups you can trust? Our team sets up automated, monitored and tested backup systems for websites, web apps and mobile backends. Contact us for a backup review.