load_remote_db 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/lib/load_remote_db/version.rb +1 -1
- data/lib/tasks/load_remote_db.rake +20 -13
- 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: b15307d40d92fd76c553d089e2960d65ce31e1cc
|
4
|
+
data.tar.gz: 5491a21958c43212756b591cf9639f3490cfe08b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e99dbedb9bcdf4140d794dace3e44681e14a9cbeb88443e00920387b493fae0ab11bda934a2014d65bf92a43fd724484f8444fe9e6aa59c349f76b697a9b545
|
7
|
+
data.tar.gz: d50d8ecd340de438c2190c5c06be4a33177cb73381d4bf1b014e64196f2a5f388dddd4e70f71cc772aa127220c8c05d6a7b971a1787a7f6e935aeab7f54f9f99
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# LoadRemoteDb
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This gem is used to download & load the remote database into your local development environment
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,18 +20,21 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
|
24
22
|
|
23
|
+
|
25
24
|
## Usage
|
26
25
|
|
27
26
|
Simply execute the command:
|
28
27
|
|
29
|
-
$ [bundle exec] rake load_remote_db:run [SERVER=environment] [SYNC_FOLDER=folder]
|
28
|
+
$ [bundle exec] rake load_remote_db:run [SERVER=environment] [SYNC_FOLDER=folder] [DOWNLOAD_ONLY=true]
|
30
29
|
|
31
30
|
For instance
|
32
31
|
|
33
32
|
$ bundle exec rake load_remote_db:run SERVER=staging
|
34
33
|
$ bundle exec rake load_remote_db:run SERVER=staging SYNC_FOLDER=public/system
|
34
|
+
$ bundle exec rake load_remote_db:run SERVER=staging DOWNLOAD_ONLY=true
|
35
35
|
|
36
36
|
|
37
|
+
gg
|
37
38
|
## Development
|
38
39
|
|
39
40
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -42,6 +43,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
42
43
|
|
43
44
|
|
44
45
|
|
46
|
+
|
45
47
|
## Contributing
|
46
48
|
|
47
49
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[jameshuynh]/load_remote_db.
|
@@ -54,3 +56,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
54
56
|
|
55
57
|
|
56
58
|
|
59
|
+
|
@@ -67,30 +67,37 @@ class RemoteDbLoader
|
|
67
67
|
download_db_dump_command =
|
68
68
|
%(scp #{@server_user}@#{@server_ip}:#{shared_path}/backup.#{bk_extension} .)
|
69
69
|
|
70
|
-
|
70
|
+
system(download_db_dump_command)
|
71
71
|
|
72
72
|
puts 'Deleting remote backup file...'
|
73
73
|
delete_db_dump_command = %(ssh #{@server_user}@#{@server_ip} \
|
74
74
|
"rm -rf #{shared_path}/backup.#{bk_extension}")
|
75
75
|
|
76
|
+
system(delete_db_dump_command)
|
77
|
+
|
76
78
|
if gzip_exist
|
77
|
-
`gunzip backup.sql.gz`
|
79
|
+
`gunzip -f backup.sql.gz`
|
78
80
|
end
|
79
81
|
|
80
|
-
if
|
81
|
-
|
82
|
-
|
82
|
+
if ENV['DOWNLOAD_ONLY']
|
83
|
+
puts 'backup.sql file is now stored at your Rails root folder!'
|
84
|
+
`open .`
|
83
85
|
else
|
84
|
-
|
85
|
-
|
86
|
+
if password == nil
|
87
|
+
import_db_cmd =
|
88
|
+
%(mysql -u #{username} #{database} < backup.sql)
|
89
|
+
else
|
90
|
+
import_db_cmd =
|
91
|
+
%(mysql -u #{username} -p'#{password}' #{database} < backup.sql)
|
92
|
+
end
|
93
|
+
|
94
|
+
puts 'Importing database into local environment...'
|
95
|
+
`#{import_db_cmd}`
|
96
|
+
|
97
|
+
puts 'Cleaning up database backup...'
|
98
|
+
`rm backup.sql`
|
86
99
|
end
|
87
100
|
|
88
|
-
puts 'Importing database into local environment...'
|
89
|
-
`#{import_db_cmd}`
|
90
|
-
|
91
|
-
puts 'Cleaning up database backup...'
|
92
|
-
`rm backup.sql`
|
93
|
-
|
94
101
|
if to_be_rsync_folder
|
95
102
|
puts "Synchorinizing #{to_be_rsync_folder} folder..."
|
96
103
|
`mkdir -p 'public/#{to_be_rsync_folder.gsub('public/', '')}'`
|