Sail Knowledgebase

How to Create a Full WordPress Backup with Sail CLI

In this article you will learn how to use the sail backup command to create and download a full site and database backup from your production server.

If you like Sail, consider sponsoring us via GitHub!

Sail backup

In your Sail project directory run:

sail backup

This will create a new archive in the hidden .backups directory on in your local working copy. The archive will contain a full backup of your application files, all your WordPress uploads, and a full WordPress database dump.

The structure of the backup is the following:

  • database.sql - the full MySQL/MariaDB database dump of your WordPress tables
  • www - the WordPress application files (core, themes, plugins, etc.)
  • uploads - the contents of the wp-content/uploads directory.

View backups

You can use ls to view full site (and database) backups available in your local working directory:

cd /path/to/project
ls -lh .backups

Delete old backups

Note that Sail does not delete old backups from your local working directory by default, so you'll need to do this manually, to avoid running out of space. For example, to delete backup archives older than 30 days, run:

cd /path/to/project
find .backups -mtime +30 -print

This will display which archives are older than 30 days. To delete them, simply replace the -print option with -delete:

cd /path/to/project
find .backups -mtime +30 -delete