mina-data_sync 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/mina/data_sync/defaults.rb +2 -1
- data/lib/mina/data_sync/tasks.rb +24 -18
- data/lib/mina/data_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe59f1e1973517be6af682959891f1b1f9aec9a5
|
4
|
+
data.tar.gz: cd92d1e1016a9794cfc08c7af325630258431b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 288ef3a12581f83977f70e5cc9c973504c37cc6846ade8fa1c6c8616b9634f732f5e38eda3e16ed74eef14a2ea7789627c06b03c31df5d8dd1ce0f37b724b33a
|
7
|
+
data.tar.gz: 784984bf74d646d5f9a2ccb5dc9522ec9a8477b79961675f9406f2a4e69cafd6bf4a358046f909fbb4e2f7855cb43b79b28470f11252bf5f698d26cb669b97c4
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ And then execute:
|
|
23
23
|
Or install it yourself as:
|
24
24
|
|
25
25
|
$ gem install mina-data_sync
|
26
|
-
|
26
|
+
|
27
27
|
Require it in your deploy script:
|
28
28
|
|
29
29
|
```ruby
|
@@ -45,8 +45,8 @@ configurable variables with defaults
|
|
45
45
|
set :database_path, "config/database.yml"
|
46
46
|
set :remote_backup_path, 'tmp'
|
47
47
|
set :local_backup_path, -> { ENV['DATA_SYNC_BACKUP_PATH'] || 'tmp' }
|
48
|
-
|
49
|
-
set :
|
48
|
+
set :restore_data, -> { ENV['restore'] || 'true' } # if false will not restore backup
|
49
|
+
set :dump_data, -> { ENV['dump'] || 'true' } # if false will not dump and copy backup
|
50
50
|
```
|
51
51
|
|
52
52
|
## Contributing
|
@@ -1,4 +1,5 @@
|
|
1
|
-
set_default :database_path,
|
1
|
+
set_default :database_path, 'config/database.yml'
|
2
2
|
set_default :remote_backup_path, 'tmp'
|
3
3
|
set_default :local_backup_path, -> { ENV['DATA_SYNC_BACKUP_PATH'] || 'tmp' }
|
4
4
|
set_default :restore_data, -> { ENV['restore'] || 'true' }
|
5
|
+
set_default :dump_data, -> { ENV['dump'] || 'true' }
|
data/lib/mina/data_sync/tasks.rb
CHANGED
@@ -6,19 +6,23 @@ namespace :data_sync do
|
|
6
6
|
task pull: :setup_sync do
|
7
7
|
set :term_mode, :pretty
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
if dump_data == 'true'
|
10
|
+
queue "echo '-----> Dumping database'"
|
11
|
+
queue "cd #{deploy_to}/#{current_path}"
|
12
|
+
queue "#{DATA_SYNC}"
|
13
|
+
queue "mkdir -p #{remote_backup_path}"
|
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
|
16
18
|
|
17
19
|
to :after_hook do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
if dump_data == 'true'
|
21
|
+
queue "echo '-----> Copying backup'"
|
22
|
+
queue "mkdir -p #{local_backup_path}"
|
23
|
+
queue "#{DATA_SYNC}"
|
24
|
+
queue "rsync --progress -e 'ssh -p #{port}' #{user}@#{domain}:#{deploy_to}/#{current_path}/#{remote_backup_path}/#{backup_file} #{local_backup_path}/#{backup_file}"
|
25
|
+
end
|
22
26
|
if restore_data == 'true'
|
23
27
|
queue "echo '-----> Restoring database'"
|
24
28
|
queue "CONFIG=$(RAILS_ENV=development #{bundle_bin} exec rails runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json')"
|
@@ -32,13 +36,15 @@ namespace :data_sync do
|
|
32
36
|
set :term_mode, :pretty
|
33
37
|
|
34
38
|
to :before_hook do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
if dump_data == 'true'
|
40
|
+
queue "echo '-----> Dumping database'"
|
41
|
+
queue "#{DATA_SYNC}"
|
42
|
+
queue "CONFIG=$(RAILS_ENV=development #{bundle_bin} exec rails runner 'puts ActiveRecord::Base.connection.instance_variable_get(:@config).to_json')"
|
43
|
+
queue %(data_sync "dump" "#{local_backup_path}/#{backup_file}" "$CONFIG")
|
44
|
+
queue %(eval $(data_sync "dump" "#{local_backup_path}/#{backup_file}" "$CONFIG"))
|
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
|
42
48
|
end
|
43
49
|
|
44
50
|
if restore_data == 'true'
|