mina-data_sync 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e548a6f89f25fd32c6ee2a3458e25fdce95a07e0
4
- data.tar.gz: 94cbfe3f9bc120243a6ec063bde02c8e0ad40d80
3
+ metadata.gz: 0e09278425980940ce64a951a1a39f5b55cf8cd0
4
+ data.tar.gz: aabf9d17edbe35492550ac3c87a75efd26a4fbb8
5
5
  SHA512:
6
- metadata.gz: d9f7d21cbcd9bed0c1a3da8fb83765387adf52ebf76f3041d2f9238b5212e5c502360ce2fd48a399ed9770608ff2977b3b669743f337620732a322f965125d12
7
- data.tar.gz: 5a1d935f2468ff6b716f695a33bb138771cbb17e3a389b3f71b386fd82c9db3fdc08f21f77a8a8d7229ea06179cf4da73497f1cfbc915ce3260754a33e4d4192
6
+ metadata.gz: 9a3cfbd6f79b31808ef15b9c6a54a33645668767c2410f7942f0ccc8f358eba32415ee2b02e962d885b75d41966ca5ed6cdc85e7a0ae9c2adeebf608921b1cfe
7
+ data.tar.gz: aef3a7b380aaeab56e2d43c24517d6e51782888db4ed2e7b0f094042a7c2656fc0f1c7ecc2b6661cf869432e71bbafff6cf1deb115e410cd0203deb5b7c66fef
data/config/database.yml CHANGED
@@ -1,39 +1,46 @@
1
- default: &default
2
- adapter: postgresql
1
+ # MySQL. Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MYSQL driver
4
+ # gem install mysql2
5
+ #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
9
+ # And be sure to use new-style password hashing:
10
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
11
+ development:
12
+ adapter: mysql2
3
13
  encoding: utf8
14
+ database: psylog_development
4
15
  pool: 5
5
- username: postgres
16
+ username: root
6
17
  password:
7
- host: localhost
8
-
9
- rakovac: &rakovac
10
- <<: *default
11
- username: <%= ENV['PGSQL_USER'] %>
12
- password: <%= ENV['PGSQL_PASSWORD'] %>
13
- host: <%= ENV['PGSQL_HOST'] %>
14
- port: <%= ENV['PGSQL_PORT'] %>
15
-
16
- # development:
17
- # adapter: mysql2
18
- # encoding: utf8
19
- # database: miramo_club_development
20
- # pool: 5
21
- # username: root
22
- # password:
23
- # host: localhost
24
-
25
- development: &development
26
- <<: *default
27
- database: miramo_club_development
28
18
 
19
+ # Warning: The database defined as "test" will be erased and
20
+ # re-generated from your development database when you run "rake".
21
+ # Do not set this db to the same as development or production.
29
22
  test:
30
- <<: *default
31
- database: miramo_club_test
23
+ adapter: mysql2
24
+ encoding: utf8
25
+ database: psylog_test
26
+ pool: 5
27
+ username: root
28
+ password:
32
29
 
33
- production: &production
34
- <<: *rakovac
35
- database: miramo_infinum_co
30
+ production:
31
+ host: localhost
32
+ adapter: mysql2
33
+ encoding: utf8
34
+ database: psylog_infinum_co
35
+ pool: 5
36
+ username: psylog_p
37
+ password: DzmKmmMw
36
38
 
37
39
  staging:
38
- <<: *rakovac
39
- database: miramo_staging_infinum_co
40
+ host: localhost
41
+ adapter: mysql2
42
+ encoding: utf8
43
+ database: psylog_staging_infinum_co
44
+ pool: 5
45
+ username: psylog_s
46
+ password: uRfbBD1S
data/config/deploy.rb CHANGED
@@ -4,9 +4,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'mina/bundler'
5
5
  require 'mina/rails'
6
6
  require 'mina/git'
7
- require 'pry'
7
+ require 'mina/whenever' # uncomment if using whenever
8
8
  require 'mina/data_sync'
9
- # require 'mina/whenever' # uncomment if using whenever
9
+
10
10
 
11
11
  # Setup project
12
12
  # - mina production setup
@@ -17,53 +17,50 @@ require 'mina/data_sync'
17
17
  # Pull data from production
18
18
  # - mina production data:pull
19
19
 
20
- set :repository, 'git@bitbucket.org:infinum_hr/web_miramoclub.git'
21
- set :backup_path, '/Users/stef/dev/databases/pg'
22
- set :port, 22220
23
- set :user, 'staging'
24
- set :domain, 'miramo.infinum.co'
20
+ set :repository, 'git@bitbucket.org:infinum_hr/web_psylog.git'
21
+ set :user, 'legacy'
22
+ set :port, 22219
25
23
 
26
24
  task :production do
27
- set :deploy_to, '/home/staging/www/m/miramo.infinum.co'
25
+ set :domain, 'psylog.eu'
26
+ set :deploy_to, '/home/legacy/www/p/psylog.eu'
28
27
  set :rails_env, 'production'
29
28
  set :branch, 'master'
30
- set :bundle_withouts, 'development:test:staging'
31
29
  end
32
30
 
33
- # If you have
34
31
  task :staging do
35
- set :domain, 'miramo.infinum.co'
36
- set :deploy_to, '/home/staging/www/m/miramo.infinum.co'
32
+ set :domain, 'psylog-staging.infinum.co'
33
+ set :deploy_to, '/home/legacy/www/p/psylog-staging.infinum.co'
37
34
  set :rails_env, 'staging'
38
- set :branch, 'develop'
39
- set :bundle_withouts, 'development:test:production'
35
+ set :branch, 'master'
40
36
  end
41
37
 
42
- task :development do
43
- set :rails_env, 'development'
44
- end
38
+
45
39
  ##################################################################################
46
40
  ########################## DO NOT EDIT THE CODE BELOW ############################
47
41
  ##################################################################################
48
42
 
49
- # While linking asssets it will only precompile that assets that was changed, not all of them
50
- set :shared_paths, ['log']
43
+ set :shared_paths, ['log', 'pids']
51
44
 
52
45
  task :deploy => :stages do
53
46
  deploy do
54
- invoke :'git:clone'
55
- invoke :'deploy:link_shared_paths'
56
- invoke :'bundle:install'
57
- invoke :'rails:db_migrate'
58
- invoke :'rails:assets_precompile'
59
- invoke :'deploy:cleanup'
47
+ to :default do
48
+ invoke :'git:clone'
49
+ invoke :'deploy:link_shared_paths'
50
+ invoke :'bundle:install'
51
+ invoke :'rails:db_migrate'
52
+ invoke :'rails:assets_precompile'
53
+ invoke :'deploy:cleanup'
54
+ end
60
55
 
61
56
  to :launch do
62
57
  # Capistrano to Mina Fix, symlink system to shared
63
58
  queue! %[echo "-----> Symlink system to shared"]
64
59
  queue! %[ln -nFs #{deploy_to}/shared/system #{deploy_to}/#{current_path}/public/system]
65
60
 
66
- #invoke :'whenever:update' # uncomment if using whenever (why here? read https://gist.github.com/gabskoro/abfc245a55a9d155f8de)
61
+ queue %[echo "-----> Restarting jobs"]
62
+ queue "RAILS_ENV=#{rails_env} #{deploy_to}/#{current_path}/bin/delayed_job restart --pid-dir=pids"
63
+
67
64
  invoke :restart_application
68
65
  end
69
66
  end
@@ -81,6 +78,38 @@ end
81
78
  task :setup => :stages do
82
79
  queue! %[mkdir -p "#{deploy_to}/shared/log"]
83
80
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
81
+
82
+ queue! %[mkdir -p "#{deploy_to}/shared/system"]
83
+ queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/system"]
84
+ end
85
+
86
+ # Import dummy data
87
+ task :import => :stages do
88
+ queue "bundle exec rake import:effects"
89
+ queue "bundle exec rake import:lifestyles"
90
+ queue "bundle exec rake import:medications"
91
+ queue "bundle exec rake import:users"
92
+ queue "bundle exec rake import:friendships"
93
+ end
94
+
95
+ task :import_effects => :stages do
96
+ queue "bundle exec rake import:effects"
97
+ end
98
+
99
+ task :import_lifestyles => :stages do
100
+ queue "bundle exec rake import:lifestyles"
101
+ end
102
+
103
+ task :import_medications => :stages do
104
+ queue "bundle exec rake import:medications"
105
+ end
106
+
107
+ task :import_users => :stages do
108
+ queue "bundle exec rake import:users"
109
+ end
110
+
111
+ task :import_friendships => :stages do
112
+ queue "bundle exec rake import:friendships"
84
113
  end
85
114
 
86
115
  # Tail log from server
@@ -95,31 +124,54 @@ task :restart_application do
95
124
  queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
96
125
  end
97
126
 
98
- namespace :data do
99
- set :pretty_print, true
100
- set :db_path, '/Users/stef/dev/databases'
127
+ # Ping application
128
+ task :ping_application do
129
+ queue %[echo "-----> Ping domain"]
130
+ queue %[curl -s #{domain} > /dev/null]
131
+ end
132
+
133
+ # Stop delayed job
134
+ task :stop_delayed_job do
135
+ queue! %[echo "-----> Stop delayed job"]
136
+ queue! %[cd #{deploy_to}/#{current_path} ; RAILS_ENV=#{rails_env} bin/delayed_job stop]
137
+ end
138
+
139
+ # Start delayed job
140
+ task :start_delayed_job do
141
+ queue! %[echo "-----> Start delayed job"]
142
+ queue! %[cd #{deploy_to}/#{current_path} ; mkdir -p tmp/pids ; RAILS_ENV=#{rails_env} bin/delayed_job start]
143
+ end
101
144
 
102
- # # Sync database
103
- # RYAML = <<-BASH
104
- # function ryaml {
105
- # ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
106
- # };
107
- # BASH
145
+ # Restart delayed job
146
+ task :restart_delayed_job do
147
+ queue! %[echo "-----> Restart delayed job"]
148
+ queue! %[cd #{deploy_to}/#{current_path} ; RAILS_ENV=#{rails_env} bin/delayed_job restart]
149
+ end
108
150
 
151
+ # Sync database
152
+ RYAML = <<-BASH
153
+ function ryaml {
154
+ ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
155
+ };
156
+ BASH
157
+
158
+ namespace :data do
109
159
  task :pull => :stages do
110
- queue RYAML
111
- queue! "HOST=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} host)"
112
- queue! "DATABASE=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} database)"
113
- queue! "USERNAME=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} username)"
114
- queue! "PASSWORD=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} password)"
115
- queue! "mysqldump $DATABASE --host=$HOST --user=$USERNAME --password=$PASSWORD > #{deploy_to}/dump.sql"
116
- queue! "gzip -f #{deploy_to}/dump.sql"
117
-
118
- to :after_hook do
119
- queue! "scp -P #{port} #{user}@#{domain}:#{deploy_to}/dump.sql.gz ."
120
- queue! "gunzip -f dump.sql.gz"
121
- queue! "#{RYAML} mysql --verbose --user=$(ryaml config/database.yml development username) --password=$(ryaml config/database.yml development password) $(ryaml config/database.yml development database) < dump.sql"
122
- queue! "rm dump.sql"
160
+ isolate do
161
+ queue RYAML
162
+ queue "HOST=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} host)"
163
+ queue "DATABASE=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} database)"
164
+ queue "USERNAME=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} username)"
165
+ queue "PASSWORD=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} password)"
166
+ queue "mysqldump $DATABASE --host=$HOST --user=$USERNAME --password=$PASSWORD > #{deploy_to}/dump.sql"
167
+ queue "gzip -f #{deploy_to}/dump.sql"
168
+
169
+ mina_cleanup!
123
170
  end
171
+
172
+ %x[scp #{user}@#{domain}:#{deploy_to}/dump.sql.gz .]
173
+ %x[gunzip -f dump.sql.gz]
174
+ %x[#{RYAML} mysql --verbose --user=$(ryaml config/database.yml development username) --password=$(ryaml config/database.yml development password) $(ryaml config/database.yml development database) < dump.sql]
175
+ %x[rm dump.sql]
124
176
  end
125
177
  end
@@ -0,0 +1,39 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ encoding: utf8
4
+ pool: 5
5
+ username: postgres
6
+ password:
7
+ host: localhost
8
+
9
+ rakovac: &rakovac
10
+ <<: *default
11
+ username: <%= ENV['PGSQL_USER'] %>
12
+ password: <%= ENV['PGSQL_PASSWORD'] %>
13
+ host: <%= ENV['PGSQL_HOST'] %>
14
+ port: <%= ENV['PGSQL_PORT'] %>
15
+
16
+ # development:
17
+ # adapter: mysql2
18
+ # encoding: utf8
19
+ # database: miramo_club_development
20
+ # pool: 5
21
+ # username: root
22
+ # password:
23
+ # host: localhost
24
+
25
+ development: &development
26
+ <<: *default
27
+ database: miramo_club_development
28
+
29
+ test:
30
+ <<: *default
31
+ database: miramo_club_test
32
+
33
+ production: &production
34
+ <<: *rakovac
35
+ database: miramo_infinum_co
36
+
37
+ staging:
38
+ <<: *rakovac
39
+ database: miramo_staging_infinum_co
@@ -0,0 +1,125 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'mina/bundler'
5
+ require 'mina/rails'
6
+ require 'mina/git'
7
+ require 'pry'
8
+ require 'mina/data_sync'
9
+ # require 'mina/whenever' # uncomment if using whenever
10
+
11
+ # Setup project
12
+ # - mina production setup
13
+ # Deploy project
14
+ # - mina production deploy
15
+ # Tail log from project
16
+ # - mina prodution log
17
+ # Pull data from production
18
+ # - mina production data:pull
19
+
20
+ set :repository, 'git@bitbucket.org:infinum_hr/web_miramoclub.git'
21
+ set :local_backup_path, '/Users/stef/dev/databases/pg'
22
+ set :port, 22220
23
+ set :user, 'staging'
24
+ set :domain, 'miramo.infinum.co'
25
+
26
+ task :production do
27
+ set :deploy_to, '/home/staging/www/m/miramo.infinum.co'
28
+ set :rails_env, 'production'
29
+ set :branch, 'master'
30
+ set :bundle_withouts, 'development:test:staging'
31
+ end
32
+
33
+ # If you have
34
+ task :staging do
35
+ set :domain, 'miramo-club.infinum.co'
36
+ set :deploy_to, '/home/staging/www/m/miramo-staging.infinum.co'
37
+ set :rails_env, 'staging'
38
+ set :branch, 'develop'
39
+ set :bundle_withouts, 'development:test:production'
40
+ end
41
+
42
+ task :development do
43
+ set :rails_env, 'development'
44
+ end
45
+ ##################################################################################
46
+ ########################## DO NOT EDIT THE CODE BELOW ############################
47
+ ##################################################################################
48
+
49
+ # While linking asssets it will only precompile that assets that was changed, not all of them
50
+ set :shared_paths, ['log']
51
+
52
+ task :deploy => :stages do
53
+ deploy do
54
+ invoke :'git:clone'
55
+ invoke :'deploy:link_shared_paths'
56
+ invoke :'bundle:install'
57
+ invoke :'rails:db_migrate'
58
+ invoke :'rails:assets_precompile'
59
+ invoke :'deploy:cleanup'
60
+
61
+ to :launch do
62
+ # Capistrano to Mina Fix, symlink system to shared
63
+ queue! %[echo "-----> Symlink system to shared"]
64
+ queue! %[ln -nFs #{deploy_to}/shared/system #{deploy_to}/#{current_path}/public/system]
65
+
66
+ #invoke :'whenever:update' # uncomment if using whenever (why here? read https://gist.github.com/gabskoro/abfc245a55a9d155f8de)
67
+ invoke :restart_application
68
+ end
69
+ end
70
+ end
71
+
72
+ # First ensure that the stage is selected
73
+ task :stages do
74
+ unless domain
75
+ print_error "A server needs to be specified. e.g. production/staging"
76
+ exit
77
+ end
78
+ end
79
+
80
+ # Just overwrote to execute stages first
81
+ task :setup => :stages do
82
+ queue! %[mkdir -p "#{deploy_to}/shared/log"]
83
+ queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
84
+ end
85
+
86
+ # Tail log from server
87
+ task :log => :stages do
88
+ queue "tail -f #{deploy_to}/#{current_path}/log/#{rails_env}.log"
89
+ end
90
+
91
+ # Restart application after deployment
92
+ task :restart_application do
93
+ queue %[echo "-----> Restarting application"]
94
+ queue "mkdir -p #{deploy_to}/#{current_path}/tmp"
95
+ queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
96
+ end
97
+
98
+ namespace :data do
99
+ set :pretty_print, true
100
+ set :db_path, '/Users/stef/dev/databases'
101
+
102
+ # # Sync database
103
+ # RYAML = <<-BASH
104
+ # function ryaml {
105
+ # ruby -ryaml -e 'puts ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[key] }' "$@"
106
+ # };
107
+ # BASH
108
+
109
+ task :pull => :stages do
110
+ queue RYAML
111
+ queue! "HOST=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} host)"
112
+ queue! "DATABASE=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} database)"
113
+ queue! "USERNAME=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} username)"
114
+ queue! "PASSWORD=$(ryaml #{deploy_to}/#{current_path}/config/database.yml #{rails_env} password)"
115
+ queue! "mysqldump $DATABASE --host=$HOST --user=$USERNAME --password=$PASSWORD > #{deploy_to}/dump.sql"
116
+ queue! "gzip -f #{deploy_to}/dump.sql"
117
+
118
+ to :after_hook do
119
+ queue! "scp -P #{port} #{user}@#{domain}:#{deploy_to}/dump.sql.gz ."
120
+ queue! "gunzip -f dump.sql.gz"
121
+ queue! "#{RYAML} mysql --verbose --user=$(ryaml config/database.yml development username) --password=$(ryaml config/database.yml development password) $(ryaml config/database.yml development database) < dump.sql"
122
+ queue! "rm dump.sql"
123
+ end
124
+ end
125
+ end
@@ -1,4 +1,3 @@
1
1
  set_default :database_path, "config/database.yml"
2
- set_default :backup_path, '.'
3
- set_default :backup_file, -> { "backup-#{Date.today}.tar" }
4
- set_default :pg_options, "-O -Ft -a"
2
+ set_default :remote_backup_path, 'tmp'
3
+ set_default :local_backup_path, 'tmp/backups'
@@ -1,4 +1,4 @@
1
- DC = <<-RUBY
1
+ ARGUMENTS = <<-RUBY
2
2
  dc = YAML.load(ERB.new(File.read(ARGV[0])).result)[ARGV[1]]
3
3
  adapter = dc["adapter"]
4
4
  database = dc["database"]
@@ -13,58 +13,47 @@ DC = <<-RUBY
13
13
  arguments += " -h " + host if host
14
14
  arguments += " -U " + username if username
15
15
  arguments += " -p " + port.to_s if port
16
- puts arguments
16
+ when "mysql2"
17
+ arguments += " " + database if database
18
+ arguments += " -h " + host if host
19
+ arguments += " -u " + username if username
20
+ arguments += " --password=" + password if password
21
+ arguments += " -P " + port.to_s if port
17
22
  end
23
+ puts arguments
18
24
  RUBY
19
25
 
20
- DATABASE_CONF = <<-BASH
21
- function database_conf {
22
- ruby -ryaml -rerb -e '#{DC}' "$@"
26
+ CONF = <<-BASH
27
+ function conf {
28
+ ruby -ryaml -rerb -e '#{ARGUMENTS}' "$@"
23
29
  };
24
30
  BASH
25
31
 
26
- # module Mina
27
- # module DataSync
28
- # class Base
29
- # def initialize(database_path, rails_env, deploy_to, tar)
30
- # @database_conf = YAML.load(ERB.new(File.read(database_path)).result)[rails_env]
31
- # @tar = tar
32
- # @deploy_to = deploy_to
33
- # end
34
-
35
- # def database
36
- # @database_conf['database']
37
- # end
38
-
39
- # def host
40
- # @database_conf['host']
41
- # end
42
-
43
- # def username
44
- # @database_conf['username']
45
- # end
32
+ def read_conf(path, rails_env)
33
+ @conf ||= YAML.load(ERB.new(File.read(path)).result)[rails_env]
34
+ end
46
35
 
47
- # def port
48
- # @database_conf['port']
49
- # end
36
+ def backup_file
37
+ "#{@conf['database']}-#{Date.today}.sql"
38
+ end
50
39
 
51
- # def file_sql
52
- # @file_sql ||= "backup-#{Date.today}.sql"
53
- # end
54
-
55
- # def file_tar
56
- # @file_tar ||= "backup-#{Date.today}.tar"
57
- # end
40
+ def dump
41
+ case @conf['adapter']
42
+ when 'postgresql' then 'pg_dump'
43
+ when 'mysql2' then 'mysqldump'
44
+ end
45
+ end
58
46
 
59
- # def file
60
- # @tar ? file_tar : file_sql
61
- # end
47
+ def restore
48
+ case @conf['adapter']
49
+ when 'postgresql' then 'psql -q'
50
+ when 'mysql2' then 'mysql --verbose'
51
+ end
52
+ end
62
53
 
63
- # def options
64
- # options = "-O -a"
65
- # options += ' -Ft' if @tar
66
- # options
67
- # end
68
- # end
69
- # end
70
- # end
54
+ def options
55
+ case @conf['adapter']
56
+ when 'postgresql' then '-O -c'
57
+ when 'mysql2' then ''
58
+ end
59
+ end
@@ -1,39 +1,43 @@
1
1
  namespace :data_sync do
2
2
  set :term_mode, :pretty
3
3
 
4
- desc "pull"
5
- task :pg_pull => :environment do
4
+ task setup_sync: :environment do
5
+ read_conf(database_path, rails_env)
6
+ end
7
+
8
+ task pull: :setup_sync do
6
9
  queue "echo '-----> Dumping database'"
7
- queue "#{DATABASE_CONF}"
8
10
  queue "cd #{deploy_to}/#{current_path}"
9
- queue "ARGS=$(database_conf #{database_path} #{rails_env})"
10
- queue! "pg_dump $ARGS #{pg_options} > #{backup_file}"
11
+ queue! "#{CONF}"
12
+ queue! "ARGS=$(conf #{database_path} #{rails_env})"
13
+ queue "mkdir -p #{remote_backup_path}"
14
+ queue! "#{dump} $ARGS #{options} > #{remote_backup_path}/#{backup_file}"
11
15
 
12
16
  to :after_hook do
13
17
  queue "echo '-----> Copying backup'"
14
- queue "#{DATABASE_CONF}"
15
- queue "ARGS=$(database_conf #{database_path} development)"
16
- queue! "scp -P #{port} #{user}@#{domain}:#{deploy_to}/#{current_path}/#{backup_file} #{backup_path}/#{backup_file}"
18
+ queue "#{CONF}"
19
+ queue "ARGS=$(conf #{database_path} development)"
20
+ queue "mkdir -p #{local_backup_path}"
21
+ queue! "scp -P #{port} #{user}@#{domain}:#{deploy_to}/#{current_path}/#{remote_backup_path}/#{backup_file} #{local_backup_path}/#{backup_file}"
17
22
  queue "echo '-----> Restoring database'"
18
- queue! "pg_restore $ARGS #{pg_options} #{backup_path}/#{backup_file}"
23
+ queue! "#{restore} $ARGS < #{local_backup_path}/#{backup_file}"
19
24
  end
20
25
  end
21
26
 
22
- desc "push"
23
- task :pg_push => :environment do
27
+ task push: :setup_sync do
24
28
  to :before_hook do
25
- queue "#{DATABASE_CONF}"
29
+ queue "#{CONF}"
26
30
  queue "echo '-----> Dumping database'"
27
- queue "ARGS=$(database_conf #{database_path} development)"
28
- queue! "pg_dump $ARGS #{pg_options} > #{backup_file}"
31
+ queue "ARGS=$(conf #{database_path} development)"
32
+ queue! "#{dump} $ARGS #{options} > #{local_backup_path}/#{backup_file}"
29
33
  queue "echo '-----> Copying backup'"
30
- queue! "scp -P #{port} #{backup_file} #{user}@#{domain}:#{deploy_to}/#{current_path}/#{backup_file}"
34
+ queue! "scp -P #{port} #{local_backup_path}#{backup_file} #{user}@#{domain}:#{deploy_to}/#{current_path}/#{remote_backup_path}/#{backup_file}"
31
35
  end
32
36
 
33
37
  queue "echo '-----> Restoring database'"
34
- queue "#{DATABASE_CONF}"
35
38
  queue "cd #{deploy_to}/#{current_path}"
36
- queue "ARGS=$(database_conf #{database_path} #{rails_env})"
37
- queue! "pg_restore $ARGS #{pg_options} #{backup_file}"
39
+ queue "#{CONF}"
40
+ queue "ARGS=$(conf #{database_path} #{rails_env})"
41
+ queue! "#{restore} $ARGS < #{remote_backup_file}/#{backup_file}"
38
42
  end
39
43
  end
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module DataSync
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
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.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stjepan Hadjic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,11 +78,10 @@ files:
78
78
  - LICENSE.txt
79
79
  - README.md
80
80
  - Rakefile
81
- - backup-2015-03-30.sql
82
- - backup-2015-03-30.tar
83
- - backup.tar
84
81
  - config/database.yml
85
82
  - config/deploy.rb
83
+ - config_pg/database.yml
84
+ - config_pg/deploy.rb
86
85
  - lib/mina/data_sync.rb
87
86
  - lib/mina/data_sync/defaults.rb
88
87
  - lib/mina/data_sync/helpers.rb