mina-data_sync 0.4.1 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mina/data_sync/defaults.rb +5 -5
- data/lib/mina/data_sync/helpers.rb +2 -2
- data/lib/mina/data_sync/tasks.rb +37 -43
- data/lib/mina/data_sync/version.rb +1 -1
- data/mina-data_sync.gemspec +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbc55191410b3e3d69b32902de3cc174063a1a36
|
4
|
+
data.tar.gz: 048278bb16f1acbe1675d2e1aab84901bda59965
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae6354d4470eb087d293ae20bf4dc085c1b93a9e5c4b18314ceff2040efa01ed1fe4aaf273b64c06cf9390af482867ad3498340a0f5aeaee10281ae49f62d4f7
|
7
|
+
data.tar.gz: c48644f25409d87141562ece0e2bf58bd7aa9b9fae1ef857352b24ed189d8ba5f4e9b236eca1eb5673f37f3ccf10a2b96e74de402fde74fb40aad3f681feba39
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
set :database_path, 'config/database.yml'
|
2
|
+
set :remote_backup_path, 'tmp'
|
3
|
+
set :local_backup_path, -> { ENV['DATA_SYNC_BACKUP_PATH'] || 'tmp' }
|
4
|
+
set :restore_data, -> { ENV['restore'] || 'true' }
|
5
|
+
set :dump_data, -> { ENV['dump'] || 'true' }
|
@@ -37,9 +37,9 @@ DATA_SYNC = <<-BASH
|
|
37
37
|
BASH
|
38
38
|
|
39
39
|
def config
|
40
|
-
"#{rails} runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json'"
|
40
|
+
"#{fetch(:rails)} runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json'"
|
41
41
|
end
|
42
42
|
|
43
43
|
def backup_file
|
44
|
-
"#{repository.split('/').last.split('.').first}-#{rails_env}-#{Date.today}.sql"
|
44
|
+
"#{fetch(:repository).split('/').last.split('.').first}-#{fetch(:rails_env)}-#{Date.today}.sql"
|
45
45
|
end
|
data/lib/mina/data_sync/tasks.rb
CHANGED
@@ -4,56 +4,50 @@ namespace :data_sync do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
task pull: :setup_sync do
|
7
|
-
|
7
|
+
run :remote do
|
8
|
+
comment 'Dumping database'
|
9
|
+
command "cd #{fetch(:current_path)}"
|
10
|
+
command "#{DATA_SYNC}"
|
11
|
+
command "mkdir -p #{fetch(:remote_backup_path)}"
|
12
|
+
command "CONFIG=$(#{fetch(:rails)} runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json')"
|
13
|
+
command %(data_sync "dump" "#{fetch(:remote_backup_path)}/#{fetch(:backup_file)}" "$CONFIG")
|
14
|
+
command %(eval $(data_sync "dump" "#{fetch(:remote_backup_path)}/#{fetch(:backup_file)}" "$CONFIG"))
|
15
|
+
end if fetch(:dump_data) == 'true'
|
8
16
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
queue "CONFIG=$(#{rails} runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json')"
|
15
|
-
queue %(data_sync "dump" "#{remote_backup_path}/#{backup_file}" "$CONFIG")
|
16
|
-
queue %(eval $(data_sync "dump" "#{remote_backup_path}/#{backup_file}" "$CONFIG"))
|
17
|
-
end
|
18
|
-
|
19
|
-
to :after_hook do
|
20
|
-
if dump_data == 'true'
|
21
|
-
queue "echo '-----> Copying backup'"
|
22
|
-
queue "mkdir -p #{local_backup_path}"
|
23
|
-
queue "rsync --progress -e 'ssh -p #{port}' #{user}@#{domain}:#{deploy_to}/#{current_path}/#{remote_backup_path}/#{backup_file} #{local_backup_path}/#{backup_file}"
|
17
|
+
run :local do
|
18
|
+
if fetch(:dump_data) == 'true'
|
19
|
+
comment 'Copying backup'
|
20
|
+
command "mkdir -p #{fetch(:local_backup_path)}"
|
21
|
+
command "rsync --progress -e 'ssh -p #{fetch(:port)}' #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/#{fetch(:remote_backup_path)}/#{fetch(:backup_file)} #{fetch(:local_backup_path)}/#{fetch(:backup_file)}"
|
24
22
|
end
|
25
|
-
if restore_data == 'true'
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
if fetch(:restore_data) == 'true'
|
24
|
+
comment 'Restoring database'
|
25
|
+
command "#{DATA_SYNC}"
|
26
|
+
command "CONFIG=$(RAILS_ENV=development #{fetch(:bundle_bin)} exec rails runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json')"
|
27
|
+
command %(data_sync "restore" "#{fetch(:local_backup_path)}/#{fetch(:backup_file)}" "$CONFIG")
|
28
|
+
command %(eval $(data_sync "restore" "#{fetch(:local_backup_path)}/#{fetch(:backup_file)}" "$CONFIG"))
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
33
|
task push: :setup_sync do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
queue "echo '-----> Copying backup'"
|
46
|
-
queue "rsync --progress -e 'ssh -p #{port}' #{local_backup_path}/#{backup_file} #{user}@#{domain}:#{deploy_to}/#{current_path}/#{remote_backup_path}/#{backup_file}"
|
47
|
-
end
|
48
|
-
end
|
34
|
+
run :local do
|
35
|
+
comment 'Dumping database'
|
36
|
+
command "#{DATA_SYNC}"
|
37
|
+
command "CONFIG=$(RAILS_ENV=development #{fetch(:bundle_bin)} exec rails runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json')"
|
38
|
+
command %(data_sync "dump" "#{fetch(:local_backup_path)}/#{fetch(:backup_file)}" "$CONFIG")
|
39
|
+
command %(eval $(data_sync "dump" "#{fetch(:local_backup_path)}/#{fetch(:backup_file)}" "$CONFIG"))
|
40
|
+
comment 'Copying backup'
|
41
|
+
command "rsync --progress -e 'ssh -p #{fetch(:port)}' #{fetch(:local_backup_path)}/#{fetch(:backup_file)} #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/#{fetch(:remote_backup_path)}/#{fetch(:backup_file)}"
|
42
|
+
end if fetch(:dump_data) == 'true'
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
44
|
+
run :remote do
|
45
|
+
comment 'Restoring database'
|
46
|
+
command "cd #{fetch(:current_path)}"
|
47
|
+
command "#{DATA_SYNC}"
|
48
|
+
command "CONFIG=$(#{fetch(:rails)} runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json')"
|
49
|
+
command %(data_sync "restore" "#{fetch(:remote_backup_path)}/#{fetch(:backup_file)}" "$CONFIG")
|
50
|
+
command %(eval $(data_sync "restore" "#{fetch(:remote_backup_path)}/#{fetch(:backup_file)}" "$CONFIG"))
|
51
|
+
end if fetch(:restore_data) == 'true'
|
58
52
|
end
|
59
53
|
end
|
data/mina-data_sync.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mina-data_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stjepan Hadjic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: mina
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 1.0.0.beta1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 1.0.0.beta1
|
69
69
|
description: Description
|
70
70
|
email:
|
71
71
|
- d4be4st@gmail.com
|
@@ -101,9 +101,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- - "
|
104
|
+
- - ">"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: 1.3.1
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
109
|
rubygems_version: 2.5.1
|