Tools: How to Manually Backup WordPress Sites via SSH

Tools: How to Manually Backup WordPress Sites via SSH

Installing the Required Tools

Linux (Ubuntu/Debian)

Windows

On the Server

Prerequisites

Step 1: SSH Into Your Server

Step 2: Create a Compressed Archive of Your Site

What each flag does:

Step 3: Download the Backup to Your Local Machine

Step 4: Don't Forget the Database

Step 5: Clean Up the Server

Restoring from a Backup

Final Thoughts 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. Option A — Windows Subsystem for Linux (WSL) (recommended): Once WSL is set up, ssh and scp are available inside the Linux shell. Option B — OpenSSH via PowerShell: 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: Before you begin, make sure you have: Open your terminal and connect to your server using SSH. Replace ip_address with your actual server IP: 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 root with your username (e.g., ssh [email protected]). Your WordPress files typically live inside the public_html directory. The following command creates a compressed .tar.gz archive of the entire folder: 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: 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 scp command 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: Then download it the same way: 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: To restore, simply reverse the process: 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. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update && -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install openssh-client -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update && -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install openssh-client -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update && -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install openssh-client wsl ---weight: 500;">install wsl ---weight: 500;">install wsl ---weight: 500;">install Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 # tar -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install tar # Debian/Ubuntu -weight: 600;">sudo -weight: 500;">yum -weight: 500;">install tar # CentOS/RHEL # mysqldump (part of the MySQL client) -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mysql-client # Debian/Ubuntu -weight: 600;">sudo -weight: 500;">yum -weight: 500;">install mysql # CentOS/RHEL # tar -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install tar # Debian/Ubuntu -weight: 600;">sudo -weight: 500;">yum -weight: 500;">install tar # CentOS/RHEL # mysqldump (part of the MySQL client) -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mysql-client # Debian/Ubuntu -weight: 600;">sudo -weight: 500;">yum -weight: 500;">install mysql # CentOS/RHEL # tar -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install tar # Debian/Ubuntu -weight: 600;">sudo -weight: 500;">yum -weight: 500;">install tar # CentOS/RHEL # mysqldump (part of the MySQL client) -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mysql-client # Debian/Ubuntu -weight: 600;">sudo -weight: 500;">yum -weight: 500;">install mysql # CentOS/RHEL ssh root@ip_address ssh root@ip_address ssh root@ip_address tar -czvf ~/public_html/backup-site.tar.gz -C ~/ public_html tar -czvf ~/public_html/backup-site.tar.gz -C ~/ public_html tar -czvf ~/public_html/backup-site.tar.gz -C ~/ public_html scp root@ip_address:~/public_html/backup-site.tar.gz ~/Downloads/ scp root@ip_address:~/public_html/backup-site.tar.gz ~/Downloads/ scp root@ip_address:~/public_html/backup-site.tar.gz ~/Downloads/ mysqldump -u root -p your_database_name > ~/public_html/backup-db.sql mysqldump -u root -p your_database_name > ~/public_html/backup-db.sql mysqldump -u root -p your_database_name > ~/public_html/backup-db.sql scp root@ip_address:~/public_html/backup-db.sql ~/Downloads/ scp root@ip_address:~/public_html/backup-db.sql ~/Downloads/ scp root@ip_address:~/public_html/backup-db.sql ~/Downloads/ rm ~/public_html/backup-site.tar.gz rm ~/public_html/backup-db.sql rm ~/public_html/backup-site.tar.gz rm ~/public_html/backup-db.sql rm ~/public_html/backup-site.tar.gz rm ~/public_html/backup-db.sql tar -xzvf backup-site.tar.gz -C ~/ tar -xzvf backup-site.tar.gz -C ~/ tar -xzvf backup-site.tar.gz -C ~/ mysql -u root -p your_database_name < backup-db.sql mysql -u root -p your_database_name < backup-db.sql mysql -u root -p your_database_name < backup-db.sql - 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 - Upload the .tar.gz file back to the server using scp - Extract it with: - Import the database with: