In this article, you’ll learn how to take a clean local copy of your WordPress site for development or testing. You’ll create a lightweight backup of your site via SSH that excludes large and unnecessary files such as media uploads, cache folders, and backup archives. This approach helps you quickly set up a local development environment without transferring gigabytes of extra data.
Prerequisites
Before starting, make sure you have the following:
- A WordPress website already installed and running on your Ecenica hosting account
- An Ecenica hosting plan with SSH access enabled; (check your plan details to confirm SSH availability)
- Basic familiarity with SSH and command-line usage
- Access to cPanel or equivalent hosting control panel.
- Sufficient free disk space in your hosting account to store the backup files. As a guide, you should have at least the same amount of free space as the size of your WordPress website and database combined.
Step 1: Connect to Your Account via SSH
Connect to your Ecenica hosting account using your SSH credentials. You can find these under SSH Access in your cPanel.
Example command:
ssh user@hostname -p 2244 -i SSH-KEY
Step 2: Navigate to Your Website Directory
Once logged in, move to the directory that contains your WordPress site (usually public_html):
cd ~
Step 3: Create a Zip Backup Excluding Large or Unnecessary Files
Run the following command to create a zip archive of your WordPress site, while excluding files and folders that aren’t needed for local work:
zip -rq public_html_backup.zip public_html \ -x "public_html/wp-content/uploads/*" \ -x "public_html/wp-content/cache/*" \ -x "public_html/wp-content/w3tc-cache/*" \ -x "public_html/wp-content/litespeed/*" \ -x "public_html/wp-content/wp-rocket-config/*" \ -x "public_html/wp-content/backup*/*" \ -x "public_html/*.zip" \ -x "public_html/*.tar.gz" \ -x "public_html/error_log" \ -x "public_html/wp-content/*.log" \ -x "public_html/vendor/*" \ -x "public_html/node_modules/*" \ -x "public_html/wp-content/aiosrs-backups/*" \ -x "public_html/wp-content/updraft/*" \ -x "public_html/wp-content/et-cache/*"
This will create a file called public_html_backup.zip in your home directory, ready for download via File Manager or SFTP.
To create a copy of a staging site or addon domain
zip -rq staging.example.com_backup.zip staging.example.com \ -x "staging.example.com/wp-content/uploads/*" \ -x "staging.example.com/wp-content/cache/*" \ -x "staging.example.com/wp-content/w3tc-cache/*" \ -x "staging.example.com/wp-content/litespeed/*" \ -x "staging.example.com/wp-content/wp-rocket-config/*" \ -x "staging.example.com/wp-content/backup*/*" \ -x "staging.example.com/*.zip" \ -x "staging.example.com/*.tar.gz" \ -x "staging.example.com/error_log" \ -x "staging.example.com/wp-content/*.log" \ -x "staging.example.com/vendor/*" \ -x "staging.example.com/node_modules/*" \ -x "staging.example.com/wp-content/aiosrs-backups/*" \ -x "staging.example.com/wp-content/updraft/*" \ -x "staging.example.com/wp-content/et-cache/*"
This will create a file called staging.example.com_backup.zip in your home directory.
Recommended Exclusions Explained
| Folder/File | Purpose | Safe to Exclude |
|---|---|---|
wp-content/uploads/ |
Media files (images, videos, PDFs) | Yes |
wp-content/cache/, w3tc-cache/, litespeed/ |
Cached content | Yes |
updraft/, aiosrs-backups/ |
Backup plugin data | Yes |
error_log, debug.log |
Log files | Yes |
vendor/, node_modules/ |
Composer/npm packages (can be reinstalled) | Yes |
Why Exclude These Files
- Speeds up the download and extraction process
- Keeps your local environment focused on code and configuration
- Prevents transferring gigabytes of unnecessary data
- Reduces potential file permission or timeout issues during transfer
Step 4: Import Your Site Locally
Once you’ve downloaded the zip file and your database:
- Extract the zip into your local web server’s folder (for example,
htdocsfor XAMPP orwwwfor LocalWP). - Export MySQL Database via phpMyAdmin or export your MySQL database via SSH
- Import your database using Sequel Ace, local phpMyAdmin or WP-CLI.
- Update your site URLs using WP-CLI:
wp search-replace 'https://yourdomain.com' 'http://localhost'
-
If needed, upload the
wp-content/uploads/folder separately for your media.