How to Manually Backup WordPress Sites via SSH

Python Developer | Audio Editor | Technical Writer | OSS Contributor | Tag Moderator @ @ThePracticalDEV | Valorant TonyPoppins #881488
Search for a command to run...

Python Developer | Audio Editor | Technical Writer | OSS Contributor | Tag Moderator @ @ThePracticalDEV | Valorant TonyPoppins #881488
No comments yet. Be the first to comment.
A no-fluff deployment runbook for getting a Cookiecutter Django project live on DigitalOcean using Docker and Traefik. Covers the full path from droplet provisioning to a working production deployment

If you’re switching between networks with different trust levels—home, café, coworking space—you probably don’t want your VPN behavior to be static. This guide walks through a clean, system-level way

Why this script exists If you've ever watched your free disk space quietly shrink over a few weeks of active development, you know the feeling: yesterday you had plenty of headroom, today your IDE is

A message from a colleague dropped into my inbox one morning: Hi Ice, now that we pushed the changes sa site, we need to scour the site for mentions of Level 1, Level 2, Level 1/2 and change them acc

Backing up your WordPress site is one of the most important maintenance tasks you can do as a site owner. While plugins like UpdraftPlus or Jetpack make this easy, knowing how to do it manually via SSH gives you full control — no third-party dependencies, no bloat, just a clean archive you own.
This guide walks you through creating a full file backup of your WordPress site directly from the server using the command line.
Before connecting to your server, make sure the necessary tools are installed on your local machine.
macOS comes with ssh and scp pre-installed. No action needed — just open Terminal and you're ready to go.
sudo apt update && sudo apt install openssh-client
Option A — Windows Subsystem for Linux (WSL) (recommended):
wsl --install
Once WSL is set up, ssh and scp are available inside the Linux shell.
Option B — OpenSSH via PowerShell:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
After installing, ssh and scp will be available directly in PowerShell or Command Prompt.
Option C — GUI alternative: Install WinSCP for a drag-and-drop interface to transfer files instead of using scp.
Your server should already have tar and mysqldump available. If for any reason they are missing, install them with:
# tar
sudo apt install tar # Debian/Ubuntu
sudo yum install tar # CentOS/RHEL
# mysqldump (part of the MySQL client)
sudo apt install mysql-client # Debian/Ubuntu
sudo yum install mysql # CentOS/RHEL
Before you begin, make sure you have:
SSH access to your server
The server's IP address
Your SSH credentials (username and password, or an SSH key)
scp or an SFTP client installed on your local machine
Open your terminal and connect to your server using SSH. Replace ip_address with your actual server IP:
ssh root@ip_address
You'll be prompted for your password (or authenticated via SSH key). Once connected, you'll be inside your server's shell.
Tip: If you're using a non-root user, replace
rootwith your username (e.g.,ssh deploy@192.168.1.100).
Your WordPress files typically live inside the public_html directory. The following command creates a compressed .tar.gz archive of the entire folder:
tar -czvf ~/public_html/backup-site.tar.gz -C ~/ public_html
| Flag | Meaning |
|---|---|
-c |
Create a new archive |
-z |
Compress with gzip |
-v |
Verbose output (shows files being archived) |
-f |
Specifies the output filename |
-C ~/ |
Changes to the home directory before archiving |
The backup file backup-site.tar.gz will be saved inside ~/public_html/.
Note: Depending on your site size, this may take a few minutes. Large media libraries will increase the archive size significantly.
Once the archive is created, exit the SSH session and run the following scp command on your local machine to download the backup:
scp root@ip_address:~/public_html/backup-site.tar.gz ~/Downloads/
This securely copies the file from your server to your local ~/Downloads/ folder.
Tip: If you're on Windows, you can use WinSCP or the built-in
scpcommand in PowerShell/WSL as an alternative.
A full WordPress backup requires both the files and the database. Your files backup covers themes, plugins, and uploads — but your posts, pages, and settings live in MySQL.
To export your database, run this on the server:
mysqldump -u root -p your_database_name > ~/public_html/backup-db.sql
Then download it the same way:
scp root@ip_address:~/public_html/backup-db.sql ~/Downloads/
Replace your_database_name with the database name found in your wp-config.php file.
To avoid using up disk space on your server, delete the backup files after downloading them:
rm ~/public_html/backup-site.tar.gz
rm ~/public_html/backup-db.sql
To restore, simply reverse the process:
Upload the .tar.gz file back to the server using scp
Extract it with:
tar -xzvf backup-site.tar.gz -C ~/
Import the database with:
mysql -u root -p your_database_name < backup-db.sql
Manual backups via SSH are reliable, fast, and give you a portable snapshot of your entire site. For production sites, consider automating this process with a cron job or combining it with offsite storage like S3 or Google Drive.
A backup you never tested is a backup you can't trust — make sure to do a test restore at least once.