capistrano-syncfiles 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/capistrano-syncfiles.gemspec +1 -1
- data/lib/capistrano/tasks/syncfiles.rake +10 -0
- data/lib/capistrano/tasks/syncfiles/rsync.rake +9 -4
- data/lib/capistrano/tasks/syncfiles/sftp.rake +17 -16
- data/lib/capistrano/tasks/syncfiles/tar.rake +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c24da0aad509d6c995486b9def72fa14f8050624
|
4
|
+
data.tar.gz: 627837c3153cc159f213d95ca8f9b859e5db8d11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49e3b3950af263136238dc78ac5ea3a4221272e8729b27af10a0d3aa4d9775550c3205788ae2837f8d414d9aee3f5066913f019b2c144579b78811f90bc5aef9
|
7
|
+
data.tar.gz: c9d8be34c597105f67aad5530176e62c75b956978335aae0b318b119adf3de6128582c451bb04534b4286ba28b4edca6e59b2ee1c003c82578412035b51c926e
|
data/README.md
CHANGED
@@ -22,6 +22,7 @@ set :syncfiles, {
|
|
22
22
|
exclude: ['fvm', 'ithemes-security', 'wc-logs'] # excluded folders/files, based on local path, works also for remote
|
23
23
|
}
|
24
24
|
}
|
25
|
+
set :syncfiles_rsync_options, '-avzuO'
|
25
26
|
|
26
27
|
set :syncfiles_roles, :all # roles to run on, default: :all
|
27
28
|
|
@@ -53,8 +54,14 @@ Capistrano tasks: http://capistranorb.com/documentation/getting-started/flow/
|
|
53
54
|
The MIT License (MIT)
|
54
55
|
|
55
56
|
### Changelog
|
57
|
+
##### 1.0.0
|
58
|
+
* add `syncfiles_rsync_options` default options
|
59
|
+
|
60
|
+
##### 0.3.0
|
61
|
+
* use `current_path` instead of `release_path`
|
62
|
+
|
56
63
|
##### 0.2.0
|
57
|
-
|
64
|
+
* add sftp strategy
|
58
65
|
|
59
66
|
##### 0.1.0
|
60
|
-
|
67
|
+
* Initial release
|
@@ -1,6 +1,16 @@
|
|
1
|
+
def get_syncfiles_base_path
|
2
|
+
fetch(:syncfiles_base_path, "#{current_path}/")
|
3
|
+
end
|
4
|
+
|
1
5
|
namespace :syncfiles do
|
2
6
|
tasks = Dir[File.expand_path("syncfiles/*.rake", File.dirname(__FILE__))]
|
3
7
|
tasks.each do |task|
|
4
8
|
load task
|
5
9
|
end
|
6
10
|
end
|
11
|
+
|
12
|
+
namespace :load do
|
13
|
+
task :defaults do
|
14
|
+
set :syncfiles_rsync_options, '-avzuO'
|
15
|
+
end
|
16
|
+
end
|
@@ -4,7 +4,7 @@ namespace :rsync do
|
|
4
4
|
"#{user}#{role.hostname}"
|
5
5
|
end
|
6
6
|
|
7
|
-
desc "Synchronise local
|
7
|
+
desc "Synchronise from local to remote folder via rsync"
|
8
8
|
task :up do
|
9
9
|
files = fetch(:syncfiles)
|
10
10
|
files.each do |local_path, config|
|
@@ -16,14 +16,16 @@ namespace :rsync do
|
|
16
16
|
on release_roles sync_roles do |role|
|
17
17
|
server = build_server_string(role)
|
18
18
|
|
19
|
-
|
19
|
+
args = fetch(:syncfiles_rsync_options)
|
20
|
+
args = args + " --rsync-path='sudo rsync'" if fetch(:use_sudo)
|
21
|
+
cmd = ["rsync #{args} #{local_path}/ #{server}:#{get_syncfiles_base_path}#{remote_path}", *exclude_args]
|
20
22
|
puts cmd.join(' ')
|
21
23
|
system cmd.join(' ')
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
desc "Synchronise
|
28
|
+
desc "Synchronise from remote to local folder via rsync"
|
27
29
|
task :down do
|
28
30
|
files = fetch(:syncfiles)
|
29
31
|
files.each do |local_path, config|
|
@@ -35,7 +37,10 @@ namespace :rsync do
|
|
35
37
|
on release_roles sync_roles do |role|
|
36
38
|
server = build_server_string(role)
|
37
39
|
|
38
|
-
|
40
|
+
args = fetch(:syncfiles_rsync_options)
|
41
|
+
args = args + " --rsync-path='sudo rsync'" if fetch(:use_sudo)
|
42
|
+
|
43
|
+
cmd = ["rsync #{args} #{server}:#{get_syncfiles_base_path}#{remote_path}/ #{local_path}", *exclude_args]
|
39
44
|
puts cmd.join(' ')
|
40
45
|
system cmd.join(' ')
|
41
46
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fun_sftp'
|
2
|
+
|
2
3
|
namespace :sftp do
|
3
4
|
def connection(server, username, password)
|
4
5
|
@connection ||= FunSftp::SFTPClient.new(server, username, password)
|
@@ -16,11 +17,11 @@ namespace :sftp do
|
|
16
17
|
handle.mkdir!(remote_directory)
|
17
18
|
end
|
18
19
|
|
19
|
-
desc "Synchronise local
|
20
|
+
desc "Synchronise from local to remote folder via sftp"
|
20
21
|
task :up do
|
21
22
|
files = fetch(:syncfiles)
|
22
23
|
files.each do |local_path, config|
|
23
|
-
remote_path = config[:remote]
|
24
|
+
remote_path = "#{get_syncfiles_base_path}#{config[:remote]}"
|
24
25
|
exclude_dir = Array(config[:exclude])
|
25
26
|
exclude_args = exclude_dir.map { |dir| "! -path '#{dir}/*'"}
|
26
27
|
sync_roles = fetch(:syncfiles_roles, :all)
|
@@ -47,34 +48,34 @@ namespace :sftp do
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
desc "Synchronise
|
51
|
+
desc "Synchronise from remote to local folder via sftp"
|
51
52
|
task :down do
|
52
53
|
files = fetch(:syncfiles)
|
53
54
|
files.each do |local_path, config|
|
54
|
-
remote_path = config[:remote]
|
55
|
+
remote_path = "#{get_syncfiles_base_path}#{config[:remote]}"
|
55
56
|
exclude_dir = Array(config[:exclude])
|
56
57
|
sync_roles = fetch(:syncfiles_roles, :all)
|
57
58
|
|
58
59
|
on primary sync_roles do |role|
|
59
|
-
|
60
|
-
|
61
|
-
puts "collecting files in #{remote_path}"
|
62
|
-
handle.glob(remote_path, "**/*").each do |remote_file|
|
63
|
-
|
64
|
-
remote_file = "#{remote_path}/#{remote_file}"
|
60
|
+
handle = connection(role.hostname, role.user, fetch(:syncfiles_sftp_password))
|
65
61
|
|
66
|
-
|
62
|
+
puts "collecting files in #{remote_path}"
|
63
|
+
handle.glob(remote_path, "**/*").each do |remote_file|
|
67
64
|
|
68
|
-
|
69
|
-
local_file.start_with?(exclude)
|
70
|
-
end
|
65
|
+
remote_file = "#{remote_path}/#{remote_file}"
|
71
66
|
|
72
|
-
|
67
|
+
local_file = remote_file.sub(remote_path, local_path)
|
73
68
|
|
74
|
-
|
69
|
+
next if exclude_dir.any? do |exclude|
|
70
|
+
local_file.start_with?(exclude)
|
75
71
|
end
|
76
72
|
|
73
|
+
`mkdir -p #{::File.dirname(local_file)}`
|
74
|
+
|
75
|
+
handle.download!(remote_file, local_file)
|
76
|
+
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
|
+
|
80
81
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
namespace :tar do
|
2
|
-
desc "Synchronise local
|
2
|
+
desc "Synchronise from local to remote folder via tar copy"
|
3
3
|
task :up do
|
4
4
|
files = fetch(:syncfiles)
|
5
5
|
files.each do |local_path, config|
|
@@ -18,14 +18,14 @@ namespace :tar do
|
|
18
18
|
|
19
19
|
on release_roles sync_roles do
|
20
20
|
upload!(archive_name, tmp_file)
|
21
|
-
execute :tar, "-xzf", tmp_file, "-C", "#{
|
21
|
+
execute :tar, "-xzf", tmp_file, "-C", "#{get_syncfiles_base_path}#{remote_path}"
|
22
22
|
execute :rm, tmp_file
|
23
23
|
end
|
24
24
|
system "rm -f #{archive_name}"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
desc "Synchronise
|
28
|
+
desc "Synchronise from remote to local folder via tar copy"
|
29
29
|
task :down do
|
30
30
|
files = fetch(:syncfiles)
|
31
31
|
files.each do |local_path, config|
|
@@ -38,7 +38,7 @@ namespace :tar do
|
|
38
38
|
sync_roles = fetch(:syncfiles_roles, :all)
|
39
39
|
|
40
40
|
on primary sync_roles do
|
41
|
-
execute :tar, "-c#{tar_verbose}zf", tmp_file, "-C", "#{
|
41
|
+
execute :tar, "-c#{tar_verbose}zf", tmp_file, "-C", "#{get_syncfiles_base_path}#{remote_path} .", *exclude_args
|
42
42
|
|
43
43
|
download!(tmp_file, archive_name)
|
44
44
|
execute :rm, tmp_file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-syncfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Hanoldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.6.
|
80
|
+
rubygems_version: 2.6.14
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: This gem provides up and down file syncing with rsync, tar or sftp. This
|