Basic sync using Rsync
This extension syncs with a remote server using rsync
With these commands:
Sync-Rsync: Sync Local to Remote
Sync-Rsync: Sync Remote to local
Sync-Rsync: Compare Local to Remote
(dry run)Sync-Rsync: Compare Remote to local
(dry run)Sync-Rsync: Kills the current sync
If no sync is running clicking the status bar item will show the output
If a sync is running clicking the status bar item will kill the running sync, see Windows Notes
Rsync installed both locally and remotely
Overall Settings (all optional):
sync-rsync.autoShowOutput
: Auto show rsync output when rsync is workingsync-rsync.autoHideOutput
: Auto hide rsync output when rsync is donesync-rsync.onSave
: syncs entire local on savesync-rsync.onSaveIndividual
: syncs the changeed file on save (onSave takes presedence)sync-rsync.executableShell
: The executable shell to run rsync in (e.g. /bin/bash)sync-rsync.executable
: The rsync executeable (e.g. rsync, C:\cygwin64\bin\rsync.exe)
Default Site Options:
sync-rsync.local
: the local location defaults to workspace (must end in path separator)sync-rsync.remote
: the rsync remote location e.g. user@remote:path (must end in path separator)sync-rsync.delete
: true or false if you want rsync to delete filessync-rsync.flags
: rsync flagssync-rsync.exclude
: rsync exclude patterns e.g. [".git",".vscode"]sync-rsync.shell
: Rsync's -e option e.g. ssh -p 1234sync-rsync.chmod
: Rsync's --chmod optionsync.rsync.options
: Array of extra rsync options, set each element using rsync.set
Sites (Completely Optional, If no sites are defined Sync Rsync creates one using defaults):
sync-rsync.sites
: Multiple Site Support Multiple Sites
For workspaces you have to define localPath
and remotePath
for each folder you want synced. e.g.
{
"folders": [
{
"path": "/home/user/project/s1"
},
{
"path": "/home/user/projects/t2"
}
],
"settings": {
"sync-rsync.sites": [
{
"localPath": "/home/user/project/s1",
"remotePath": "user@server:/var/www/s1"
},
{
"localPath": "/home/user/projects/t2",
"remotePath": "user@server:/var/www/s2"
}
]
}
}
Sites have these options, they are all optional sync-rsync will use the defaults if they are not defined:
localPath
: the local location defaults to workspace (must end in path separator)remotePath
: the rsync remote location e.g. user@remote:path (must end in path separator)deleteFiles
: true or false if you want rsync to delete filesflags
: rsync flagsexclude
: rsync exclude patterns e.g. [".git",".vscode"]shell
: Rsync's -e option e.g. ssh -p 1234afterSync
: a command to run after successful sync up (e.g. clear cache). First item in array is the command the rest are arguments. e.g. ['ssh','user@server','~/cr.sh']chmod
: Rsync's --chmod optionoptions
: Array of extra rsync options, set each element using rsync.set
localPath and remotePath will replace ${workspaceRoot} with the current Workspace Path
Example :
{
"sync-rsync.delete": true,
"sync-rsync.sites": [
{
"remotePath":"user1@server1:/path1/", // Sync sync-rsync.local to user1@server1:/path1/ using port 1234
"shell":"ssh -p 1234"
},
{
"remotePath":"user2@server2:/path2/", // Sync sync-rsync.local to user2@server2:/path2/
},
{
"localPath":"project/static/",
"remotePath":"user3server3:/static/", // Sync project/static/ to user3@server3:/static/
}
]
}
If you are using rsync that uses cygwin you will need to set sync-rsync.local
and sync-rsync.remote
to use cygwin drives e.g.:
"sync-rsync.local": "/cygdrive/c/Users/joe/Documents/projects/sync_test/"
You may also need to set sync-rsync.executable
to your cygwin rsync:
"sync-rsync.executable": "C:\cygwin64\bin\rsync.exe"
If you are using the shell
option to do something like ssh -p 123
you will most likely have the set sync-rsync.executableShell
to /bin/bash