Get the Best WordPress Backup
& Migration Plugin Today
Get Duplicator Now
Announcement Duplicator WP-CLI commands

Announcing Duplicator WP-CLI Commands (And How They Speed Up Backups)

Looking for a smarter way to manage site backups? Explore Duplicator's new features, including customizable WP-CLI commands and permission settings!
WordPress backup SSH

How to Back Up WordPress with SSH 

Written By: author avatar Joella Dunn
author avatar Joella Dunn
Joella is a writer with years of experience in WordPress. At Duplicator, she specializes in site maintenance — from basic backups to large-scale migrations. Her ultimate goal is to make sure your WordPress website is safe and ready for growth.
     Reviewed By: reviewer avatar John Turner
reviewer avatar John Turner
John Turner is the President of Duplicator. He has over 20+ years of business and development experience and his plugins have been downloaded over 25 million times.

Website backups are like safety nets for your WordPress site. They protect your hard work from unexpected issues.

There are many ways to back up your WordPress site. Some are simple, like using a backup plugin. Others, like today’s method, use more advanced techniques.

This guide focuses on using SSH for WordPress backups. It’s a powerful method that offers more speed and control.

We’ll be using SSH, along with WP-CLI. Together, these tools create a reliable backup process for your website.

Let’s dive into how you can back up your WordPress site with SSH!

Table of Contents

What Is SSH?

SSH stands for Secure Shell. Think of it as a secure tunnel between your computer and your website’s server. It allows you to access and control your server remotely.

This means you can send commands to your server from your computer without compromising your WordPress security.

It’s a protocol that provides a secure, encrypted way to communicate. This is important because it protects your information when you’re interacting with your server. Without encryption, your data could be intercepted by others.

SSH is a standard tool for server administration. It is widely used by web developers and system administrators.

Using SSH, you can execute commands on your server. You can manage site files, run updates, and perform backups without needing your dashboard, file manager, or FTP client.

Why Back Up WordPress with SSH?

Using SSH for backups offers several advantages over other methods. It’s a more efficient and powerful way to protect your website. Let’s look at some key benefits.

First, speed is a big plus. SSH connections are typically much faster than browser-based methods. This is especially noticeable on larger sites with lots of data.

Second, efficiency is improved because commands run directly on the server. This avoids the extra steps of going through the website interface.

You can use scripts with SSH to automate your backups. It’ll saves time and reduce the risk of human error.

Next, you get more control with SSH. You can customize the backup process more than with simpler methods. You’ll have more flexibility to suit your specific needs.

How to Back Up Your WordPress Site with SSH

Now I’ll walk you through backing up your WordPress site using SSH. It’s a bit more technical than other backup methods, but it’s worth the effort!

Step 1: Connect to Your Website with SSH

To start, you need to connect to your server using an SSH client. If you’re using macOS or Linux, you can use the built-in Terminal application. If you’re on Windows, you can use a program like PuTTY.

You’ll need a few pieces of information. SSH requires your server’s address, your username, and your SSH password or private key. Your web hosting provider should give you these details.

For example, DreamHost users can go to Websites » SFTP Users & Files. Enable Secure Shell Access (SSH) and copy the Files Access information.

DreamHost SSH credentials

Then, open your computer’s command line. I’m on a macOS computer, so I’ll use Terminal.

Use this command to connect to your site via SSH:

Clean Code Block
Copied!

ssh username@hostname
        

Enter your SSH password when prompted.

Step 2: Install WP-CLI

WP-CLI is a command-line interface for WordPress. It allows you to manage your WordPress website directly from the terminal.

It simplifies many WordPress management tasks. You can run updates, manage users, and more using simple commands. It’s faster and more efficient than using the WordPress dashboard for many operations.

To install WP-CLI, download the Phar build:

Clean Code Block
Copied!

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
        

Then, use this command to check if the file was downloaded properly:

Clean Code Block
Copied!

php wp-cli.phar --info
        

If everything is working, you’ll see the WP-CLI version number.

Next, make the file executable and move it into your PATH.

Clean Code Block
Copied!

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
        

Then, run this command:

Clean Code Block
Copied!

wp --info
        

You’ll know WP-CLI is installed and working if you see this output:

Clean Code Block
Copied!

OS:  Linux 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017 x86_64
Shell:   /usr/bin/zsh
PHP binary:    /usr/bin/php
PHP version:     7.1.12-1+ubuntu16.04.1+deb.sury.org+1
php.ini used:   /etc/php/7.1/cli/php.ini
MySQL binary:
MySQL version:
SQL modes:
WP-CLI root dir:        /home/wp-cli/.wp-cli
WP-CLI packages dir:    /home/wp-cli/.wp-cli/packages/
WP-CLI global config:   /home/wp-cli/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 1.5.0
        

Step 3: Install Duplicator Pro

WP-CLI doesn’t have many built-in commands to back up your WordPress site. That’s where Duplicator comes in.

Duplicator is a popular WordPress plugin for backups and migrations. With it’s WP-CLI commands, you can easily customize backups from the command line.

Duplicator Pro plugin

Duplicator Pro comes with support for WP-CLI backup commands. So, you’ll need to download the plugin from the Duplicator website after purchasing it.

Although you can install Duplicator Pro from the command line, you won’t be able to configure the license key. Since you’ll have to come back to your admin dashboard anyway, let’s install and activate Duplicator here.

Then, go to Duplicator Pro » Settings » General. Paste and activate your license key.

Activate Duplicator license key

With Duplicator Pro installed, activated, and licensed, you’re ready for the next step: backing up a WordPress site using SSH.

Step 4: Back Up Your WordPress Site

Now, go back to the command line. It’s time to create a backup with SSH, WP-CLI, and Duplicator.

Duplicator Pro works with WP-CLI to create a backup remotely. To do this, use this command:

Clean Code Block
Copied!

wp duplicator build
        

When you run this command, Duplicator will begin creating a backup. It may take a few moments as it scans your site and compresses all of your WordPress files and database tables into a zip file.

SSH Duplicator backup

When complete, you’ll have a new backup of your site. These files will be on the Backups page of your WordPress admin dashboard.

Duplicator will automatically use the template of the last backup you created. However, you can easily customize this backup in your command.

Here are some flags to customize Duplicator backups:

  • --template=<ID: Use a predefined backup template.
  • --dir=<path>: Specify a custom backup location.
  • --delete: Automatically remove the backup after creation.
  • --phpsqldump, --phpzip, --duparchive: Change the archive engine used for backups.

You can combine these options as needed. For example, you might need to create a backup using a specific template, in a custom directory, with a different archive engine.

If you have a WordPress database backup template, you can customize Duplicator to back up your database. Your command might look like this:

Clean Code Block
Copied!

wp duplicator build --template="DB Backup" --dir=/home/user/backups --duparchive
        

Enter the command wp duplicator build --help for a full overview of all the available options.

You’ve successfully backed up your site using SSH! This is much easier and faster than backing up a WordPress site manually.

Frequently Asked Questions (FAQs)

What if I don’t have SSH access?

If you don’t have SSH access, you’ll need to contact your hosting provider. They can enable SSH access for your account.

It’s important to note that not all hosting providers offer SSH access. If yours doesn’t, you may need to consider moving to a different provider that supports it.

Do I need WP-CLI to back up WordPress with SSH?

Yes, WP-CLI is essential for backing up WordPress with SSH. It allows you to execute commands to interact with WordPress directly from the command line. Without WP-CLI, you can’t run the wp duplicator build command that’s needed for remote backups with Duplicator Pro.

What are the benefits of using SSH over SFTP?

While both SSH and SFTP provide secure connections, SSH is primarily used for executing commands on a server, and SFTP is mainly for transferring files.

SSH is necessary for using WP-CLI, which is key for important WordPress tasks like backups. SFTP, while secure, does not offer the same level of control and automation.

Can I schedule backups with Duplicator and WP-CLI?

While the wp duplicator build command itself doesn’t schedule backups, you can combine it with server-side tools like cron jobs to automate your backup process.

Final Thoughts

Using SSH for backups is fast, efficient, and allows for greater control and automation. It’s a step up from simpler, browser-based methods.

Once you’re comfortable with the process, you’ll find it’s a much more effective approach. You’ll have greater confidence in your backups and be better prepared for any unexpected issues.

While you’re here, I think you’ll like these extra WordPress guides:

Ready to make your data safer? Upgrade to Duplicator Pro today to unlock backup WP-CLI commands that are fast and efficient!

author avatar
Joella Dunn Content Writer
Joella is a writer with years of experience in WordPress. At Duplicator, she specializes in site maintenance — from basic backups to large-scale migrations. Her ultimate goal is to make sure your WordPress website is safe and ready for growth.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. We only recommend products that we believe will add value to our readers.