Skip to main content

File Transfers

Transfer files to and from your staging environment using SCP, rsync, or SFTP.

SCP (Secure Copy)

SCP is the simplest way to copy files.

Upload Files

# Upload a single file
scp local-file.txt mysite-staging@ssh.myscalablesite.com:/var/www/html/

# Upload to a specific directory
scp my-plugin.php mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/plugins/

# Upload a directory (recursive)
scp -r ./my-plugin/ mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/plugins/

Download Files

# Download a file
scp mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-config.php ./

# Download a directory
scp -r mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/uploads/ ./backup/

Rsync

Rsync is more efficient for syncing directories, as it only transfers changed files.

Sync Local to Remote

# Sync a plugin directory
rsync -avz ./my-plugin/ mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/plugins/my-plugin/

# Sync a theme
rsync -avz ./my-theme/ mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/themes/my-theme/

Sync Remote to Local

# Backup wp-content
rsync -avz mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/ ./backup/wp-content/

# Backup uploads only
rsync -avz mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/uploads/ ./backup/uploads/

Mirror with Delete

Destructive Operation

The --delete flag removes files from the destination that don't exist in the source.

# Mirror local theme to remote (deletes extra files on remote)
rsync -avz --delete ./my-theme/ mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/themes/my-theme/

Rsync Options Explained

OptionDescription
-aArchive mode (preserves permissions, timestamps, etc.)
-vVerbose output
-zCompress during transfer
--deleteDelete files not in source
--dry-runShow what would be transferred without doing it
--excludeExclude files matching pattern

Exclude Files

# Sync but exclude certain files
rsync -avz --exclude='node_modules' --exclude='.git' ./my-theme/ mysite-staging@ssh.myscalablesite.com:/var/www/html/wp-content/themes/my-theme/

SFTP

SFTP provides an interactive file browser.

Interactive Session

sftp mysite-staging@ssh.myscalablesite.com

SFTP Commands

Once connected, you can use these commands:

CommandDescription
lsList remote files
llsList local files
cdChange remote directory
lcdChange local directory
pwdPrint remote working directory
lpwdPrint local working directory
get fileDownload file
put fileUpload file
mkdir dirCreate remote directory
rm fileDelete remote file
exitClose connection

Example Session

sftp mysite-staging@ssh.myscalablesite.com
sftp> cd wp-content/plugins
sftp> ls
sftp> put my-plugin.zip
sftp> exit

GUI Clients

You can also use graphical SFTP clients:

Configure them with:

  • Host: ssh.myscalablesite.com
  • Port: 22
  • Protocol: SFTP
  • Username: {slug}-staging
  • Authentication: SSH Key