You can use rsync
, scp
or SFTP to upload and download files to / from your sites. All methods use SSH behind the scenes.
We recommend you upload to staging first, verify that the site looks alright and then push to live.
rsync
Rsync is the most efficient upload method as it only transfers differences between your computer and a remote destination. We recommend it over scp
and SFTP.
Getting rsync
On macOS and Linux, rsync
is most commonly pre-installed.
On Windows, we recommend you use Git Bash and download rsync
as an additional package from the MSYS2 repository – more info here.
Working with rsync
Let's upload an awesome-theme
folder to site's wp-content/themes
. First, add this to your ~/.ssh/config
file:
Host mysite
HostName ssh-staging.versionpress.com
User ih6n2tu9
Port 30860
All the values come from the SSH tab in the portal.
You can now upload the awesome-theme
folder, referring to the remote destination just as "mysite":
rsync -azv awesome-theme mysite:/var/www/html/wp-content/themes/
If you want to skip the ~/.ssh/config
step, the raw command would look like this:
rsync -azv \
-e 'ssh -p 30860' \
awesome-theme \
ih6n2tu9@ssh-staging.versionpress.com:/var/www/html/wp-content/themes/
Trailing slashes are generally significant for rsync. Uploading awesome-theme
to /remote/path
will create /remote/path/awesome-theme/style.css
. Uploading awesome-theme/
would lead to /remote/path/style.css
.
You can use `-n` / `--dry-run` (typically in a combination `-azvn`) to preview the sync.
Another useful option is --delete
which removes files from remote that no longer exist locally, essentially mirroring the directory:
rsync -azv --delete awesome-theme mysite:/var/www/html/wp-content/themes
Useful resources
tldr rsync
- Nice tutorial by DigitalOcean
- Usage examples
- Deploying code with rsync – also contains WordPress-specific examples
scp
scp
("secure copy") is another way to upload files from command line – simpler but not as efficient as rsync.
You would upload a theme like this:
scp -r awesome-theme mysite:/var/www/html/wp-content/themes
SFTP
Uploading via SFTP has several pros and cons:
- ➕ There are many SFTP clients available, for example WinSCP or Cyberduck.
- ➕ Most editors and IDEs support SFTP.
- ➕ You can mount SFTP as a local folder.
- ➖ SFTP is much slower and less reliable than rsync.
- ➖ You need to be careful which apps you use, for example, FileZilla sometimes bundles strange software.
Find connection info on the SFTP tab on your site:
If you have some SFTP app installed, you can even click the button in the portal and it should launch with the correct connection info.