Keep remote directories in sync with local project folders.
This plugin will let you sync your project folders to one or more remote servers using rsync and ssh.
remote
is a local project folder configured for sync.destination
is a path on specific server as a specific user.remote
can have one or more destinations
ssh
and rsync
installed, both locally and on the remote server.ssh-agent
. On OS X you'll need to add your keys to the Keychain by using ssh-add -K
, once this is done OS X will use ssh-agent
to query the Keychain for your password.~/.ssh/authorized_keys
.For more info on creating and using ssh keys please see this nice guide.
Note you can see everything this plugin does by viewing its output on the console.
First create a Sublime Project, you do this by adding one or more folders and then saving your project.
Then you go to the Project
menu and select Rsync SSH
and then Initialize Settings
, this will add the rsync_ssh
block to settings
with some reasonable defaults and then open the preferences for you to edit.
Be aware that the --delete
option will destroy the directory you speficy in remote_path
- as a courtesy I've added --dry-run
so you can test your config before running rsync
for real.
.sublime-project
fileNote that the .sublime-project
is a JSON file, and as such comments are not supported, fortunately for us Sublime Text uses a a rather lax parser that supports //
comments.
The comments below have just been added to document the individual sections .
When you initialize your project via Initialize Settings
the plugin will add the rsync_ssh
config to your project file.
{
"folders":
[
{
"follow_symlinks": true,
"path": "my-project-folder"
}
],
"settings":
{
// This is the block the plugin adds to your project file
"rsync_ssh":
{
// To use non-standard ssh specify the path here ...
"ssh_binary": "/usr/local/bin/ssh",
// ... and additional arguments here
"ssh_args": ["-F", "~/another/config/file"],
// To disable sync on save set 'sync_on_save' to false
"sync_on_save": true,
// To always sync all files when saving (not just the saved file)
// set `sync_all_on_save` to true
"sync_all_on_save": true,
// Rsync options
"options":
[
"--dry-run",
"--delete",
// Override how we handle permissions, useful for platforms that does not support Unix permissions.
// Here we tell rsync to use the umask on the destination to set the permissions
"--no-perms", "--chmod=ugo=rwX"
],
// Stuff we do not want rsync to copy
"excludes":
[
".git*",
"_build",
"blib",
"Build"
],
// Servers we want to sync to
"remotes":
{
// Each folder from the project will be added here
"my-project-folder":
[
{
// You can disable any destination by setting this value to 0
"enabled": 1,
// Stuff we do not want rsync to copy, but just for this destination
"excludes":
[
],
// ssh options
"remote_host": "my-server.my-domain.tld",
"remote_path": "/home/you/Projects/my-project",
"remote_port": 22,
"remote_user": "you",
// Run commands before and after rsync
"remote_pre_command": "",
"remote_post_command": ""
}
],
// Syncing a single subfolder is also supported
"my-project-folder/subfolder":
[
{
// You can disable any destination by setting this value to 0
"enabled": 0,
// Stuff we do not want rsync to copy, but just for this destination
"excludes":
[
],
// ssh options
"remote_host": "my-server.my-domain.tld",
"remote_path": "/home/you/Projects/my-subfolder-target",
"remote_port": 22,
"remote_user": "you",
// Run commands before and after rsync
"remote_pre_command": "",
"remote_post_command": ""
}
]
}
}
}
}
Just save the file normally, as this will trigger a save event which makes this plugin sync the file to all enabled remotes.
Press ⌘⇧F11 to select a specific remote or destination to sync. When selecting a specific destination the enabled
flag is overridden and the folder will always be synced.
If you select a remote, and then select the All
destination, then the enabled
flag will be respected.
If you select a remote with just one destination sync will started immediately and the enabled
flag will be overridden.
Press ⌘⇧F12 to sync all folders to all enabled remotes. - Note you must do this at least once in order to create the project folder on the remote servers.
You install this plugin either by cloning this project directly, or by installing it via the excellent Package Control plugin. Press ⌘⇧P and type Package Control: Install Package
and select it, then type the package name rsync-ssh and select it.
To use this plugin on Windows you must install Cygwin first.
You probably forgot to remove --dry-run
from the rsync options in the project configuration file.
As Windows doesn't have native support for Unix permissions, you can't rely on the default sync mode of "preserve permissions".
Instead you can turn off the persission sync with --no-perms
and then use --chmod=ugo=rwX
to make rsync
use the umask on the destination to determine which permissions a file should have.
When you initialize the rsync-ssh
configuration this will be automatically added to the configuration as shown in the example above.
remotes
to folders
(Calling them remotes is kinda silly).© 2013-2015 David Olrik [david@olrik.dk](mailto:david@olrik.dk).
This is free software. It is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. Feel free to use this package in your own work. However, if you modify and/or redistribute it, please attribute me in some way, and distribute your work under this or a similar license.