Skip to main content
Serverlys
Hosting

How to Back Up and Restore a Website with cPanel or SSH

Learn how to create full website backups using cPanel, SSH, and automation tools. Step-by-step guide covering backup creation, scheduling, cloud storage

Serverlys6 min read

Website backups are like insurance: you do not appreciate them until you need one. A bad theme update, a hacked admin account, an accidental file deletion, or a corrupted database can all take your site offline. Without a backup, recovering from any of these scenarios means rebuilding from scratch — which can take days or weeks and cost thousands of dollars in lost revenue.

This tutorial covers four backup methods, from beginner-friendly cPanel tools to advanced SSH scripts. We also cover how to restore from a backup when things go wrong.

The 3-2-1 Backup Rule

Before diving into the methods, understand the golden rule of backups:

  • 3 copies of your data (the original plus two backups)
  • 2 different storage types (e.g., server + cloud storage)
  • 1 copy offsite (not on the same server as your website)

A backup stored on the same server as your website is not a real backup. If the server fails, you lose both your site and your backup. Always store at least one copy in a separate location like Google Drive, Dropbox, Amazon S3, or a local hard drive.

What Should You Back Up?

A complete website backup includes two parts:

  1. Files: All website files including HTML, CSS, JavaScript, images, plugins, themes, uploads, and configuration files (like .htaccess and wp-config.php).
  2. Database: The MySQL database containing your content, pages, posts, comments, user accounts, settings, and plugin data.

You need both. Restoring files without the database gives you an empty website shell. Restoring the database without files gives you content with no design or functionality.

Method 1: Full Backup via cPanel

cPanel includes a built-in backup tool that creates a compressed archive of your entire hosting account, including all files, databases, email accounts, and settings.

Creating a Full Backup

  1. Log in to your cPanel dashboard.
  2. Go to Files → Backup Wizard (or Backup for the advanced view).
  3. Click Back Up (Step 1).
  4. Select Full Backup.
  5. Choose the backup destination:
  6. — Home Directory: Saves the backup to your hosting account (quickest, but uses your disk space).
  7. — Remote FTP Server: Sends the backup to an external FTP server.
  8. — Remote FTP Server (passive): Same as above but uses passive FTP mode.
  9. — SCP (Secure Copy): Sends the backup to a remote server via SSH.
  10. Enter your email address to receive a notification when the backup is complete.
  11. Click Generate Backup.

The backup process runs in the background. Depending on the size of your account, it can take anywhere from a few minutes to an hour. You will receive an email when it is done.

Downloading Partial Backups

If you only need to back up specific parts of your account, cPanel lets you download partial backups:

  • Home Directory: Downloads a compressed archive of all files.
  • MySQL Databases: Downloads individual database SQL dumps.
  • Email Forwarders and Filters: Downloads email configuration data.

Method 2: Database Backup via phpMyAdmin

For a quick database-only backup (useful before updating WordPress or running database operations):

  1. In cPanel, go to Databases → phpMyAdmin.
  2. Select your WordPress database from the left sidebar.
  3. Click the Export tab.
  4. Select Quick export method and SQL format.
  5. Click Export. Your browser will download a .sql file containing the entire database.

Restoring a Database from phpMyAdmin

  1. Open phpMyAdmin and select your database.
  2. If restoring over existing data, click Operations and select Drop all tables first. (Be very careful with this step.)
  3. Click the Import tab.
  4. Click Choose File and select your .sql backup file.
  5. Click Import. The database will be restored.

Method 3: SSH Backup Script

For developers and advanced users, SSH provides the fastest and most flexible backup method. You can create scripts that back up both files and databases, compress them, and upload them to cloud storage automatically.

Manual SSH Backup

Connect to your server via SSH and run these commands:

# Create a dated backup directory
mkdir -p ~/backups

# Back up all website files
tar -czf ~/backups/files-$(date +%Y%m%d).tar.gz -C ~/public_html .

# Back up the MySQL database
mysqldump -u dbuser -p'dbpassword' dbname > ~/backups/database-$(date +%Y%m%d).sql

# Compress the database dump
gzip ~/backups/database-$(date +%Y%m%d).sql

Replace dbuser, dbpassword, and dbname with your actual database credentials (found in wp-config.php for WordPress sites).

Automated Daily Backups with Cron

Create a backup script and schedule it to run daily using cron:

  1. Create the backup script:
#!/bin/bash
# backup.sh - Daily website backup script

BACKUP_DIR="$HOME/backups"
DATE=$(date +%Y%m%d-%H%M)
SITE_DIR="$HOME/public_html"
DB_NAME="your_database"
DB_USER="your_dbuser"
DB_PASS="your_dbpass"

# Create backup directory
mkdir -p "$BACKUP_DIR"

# Backup files
tar -czf "$BACKUP_DIR/files-$DATE.tar.gz" -C "$SITE_DIR" .

# Backup database
mysqldump -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" | gzip > "$BACKUP_DIR/db-$DATE.sql.gz"

# Delete backups older than 30 days
find "$BACKUP_DIR" -type f -mtime +30 -delete

echo "Backup completed: $DATE"
  1. Make it executable: chmod +x ~/backup.sh
  2. Add a cron job in cPanel (Cron Jobs section) or via command line:
# Run daily at 3:00 AM
0 3 * * * /home/username/backup.sh >> /home/username/backups/backup.log 2>&1

Method 4: WordPress Backup Plugins

If you are running WordPress, backup plugins offer the most user-friendly experience with cloud storage integration:

UpdraftPlus (Recommended)

  1. Install and activate UpdraftPlus from Plugins → Add New.
  2. Go to Settings → UpdraftPlus Backups.
  3. Click the Settings tab and configure:
  4. — Backup schedule: Daily for files, daily for database.
  5. — Retention: Keep the last 14 backups.
  6. — Remote storage: Choose Google Drive, Dropbox, Amazon S3, or another cloud provider. Authenticate with your account.
  7. Click Save Changes.
  8. Click Backup Now to create your first backup immediately.

Restoring with UpdraftPlus

  1. Go to Settings → UpdraftPlus Backups.
  2. Under "Existing Backups," find the backup you want to restore.
  3. Click Restore.
  4. Select which components to restore (plugins, themes, uploads, database, other).
  5. Click Restore and wait for the process to complete.
The best backup is one you have tested. Create a backup, then practice restoring it on a staging site. If you have never restored a backup before, you do not actually have a backup — you have a file you hope works.

Restoring a Full cPanel Backup

If you created a full cPanel backup and need to restore it:

  1. Contact your hosting provider. Full cPanel backups must be restored by the server administrator. Open a support ticket with Serverlys and provide the backup file.
  2. If you have SSH access and the appropriate permissions, you can use the cPanel restore API, but this requires root or reseller access.

Restoring Files from a Partial Backup

  1. In cPanel, go to Backup → Restore.
  2. Under "Restore a Home Directory Backup," click Choose File.
  3. Select the compressed home directory backup file.
  4. Click Upload. cPanel will extract the files to their original locations.

Restoring a Database from a Partial Backup

  1. In cPanel, go to Backup → Restore.
  2. Under "Restore a MySQL Database Backup," click Choose File.
  3. Select the .sql or .sql.gz backup file.
  4. Click Upload. The database will be restored.

Backup Best Practices

  • Automate everything. Manual backups are backups you will forget to make. Set up automated daily backups.
  • Store backups offsite. Use Google Drive, Dropbox, Amazon S3, or another cloud provider. Never rely solely on server-side backups.
  • Test your backups. Restore a backup to a staging environment at least once a month to verify it works.
  • Back up before changes. Always create a manual backup before updating WordPress core, themes, plugins, or making database changes.
  • Keep multiple versions. Retain at least 30 days of daily backups. Some problems (like malware) are not discovered immediately.
  • Monitor backup success. Check your backup logs or email notifications regularly to ensure backups are completing successfully.

Frequently Asked Questions

How often should I back up my website?

Daily is the minimum recommendation. If your site changes frequently (ecommerce stores with new orders, active blogs with daily posts), consider multiple backups per day. The goal is to minimize data loss — if your latest backup is 24 hours old, you lose up to 24 hours of changes in a disaster.

How much storage do backups need?

A typical WordPress site with a 500MB file directory and a 100MB database creates backups around 150–200MB when compressed. Keeping 30 daily backups requires roughly 5–6 GB of storage. Cloud storage for this amount costs $1–2/month.

Can I restore a backup to a different hosting provider?

Yes. If you have separate file and database backups, you can restore them on any hosting account. Upload the files via FTP, import the database via phpMyAdmin, and update wp-config.php with the new database credentials.

What is the difference between incremental and full backups?

A full backup copies everything every time. An incremental backup only copies files that have changed since the last backup. Incremental backups are faster and use less storage, but restoration requires the full backup plus all subsequent incremental backups.

Will backups slow down my website?

Backups use server resources (CPU and I/O) while they are running. Schedule backups during low-traffic hours (e.g., 3:00 AM) to minimize impact. On well-provisioned servers, the performance impact is negligible.

Questions about anything above? We answer them without a sales script.

A plan that still makes sense in year two

Free migration, free SSL and daily backups on every plan, with a 30-day money-back guarantee.

Prefer the phone? (305) 671-1272 · Existing customer? Client login

Your privacy

We store only what the site needs to work, like a notice you closed or your domain shortlist. No advertising or analytics cookies, and no third-party trackers. Privacy policy