pave 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pave/database.rb +16 -14
- data/lib/pave/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: 92bc7d3b71cb5170eff91764d6aec3371d4569bf
|
4
|
+
data.tar.gz: a994335d36950a0e571481bf7c7d251ddde93ab2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35094277dbd738dfbcc043c89637f05a9a38ba79d0febe9c50bbe8358b49c01c7403ee4ace7d713b4be22de2a820dcc285a4333336f9fff80679d23bfd40efb2
|
7
|
+
data.tar.gz: c9fbe417578f21221f27a29e5b1752ce590d0129448f79cd0cb58a27658bfcf37a9d2dc3e2349fe0942ae4727ad7f05d3795034b36c0ce02e9b599a2e4597cb1
|
data/lib/pave/database.rb
CHANGED
@@ -42,8 +42,8 @@ module Pave
|
|
42
42
|
"#{Pave::Remote.server(remote)}:#{Pave::Remote.directory(remote)}"
|
43
43
|
end
|
44
44
|
|
45
|
-
def dump_file
|
46
|
-
"#{Time.now.strftime("%Y-%m-%d")}-#{name}.sql.gz"
|
45
|
+
def dump_file(which_db)
|
46
|
+
"#{Time.now.strftime("%Y-%m-%d")}-#{name}-#{which_db}.sql.gz"
|
47
47
|
end
|
48
48
|
|
49
49
|
def dump
|
@@ -53,52 +53,54 @@ module Pave
|
|
53
53
|
sh "echo 'deny from all' > ./db/.htaccess"
|
54
54
|
sh "sudo chmod -R 700 ./db/"
|
55
55
|
end
|
56
|
-
say "Creating dump of #{name} at #{Dir.pwd}/db/#{dump_file}"
|
57
|
-
sh "mysqldump -uroot #{name} | gzip > ./db/#{dump_file}"
|
56
|
+
say "Creating dump of #{name} at #{Dir.pwd}/db/#{dump_file(:local)}"
|
57
|
+
sh "mysqldump -uroot #{name} | gzip > ./db/#{dump_file(:local)}"
|
58
58
|
end
|
59
59
|
|
60
60
|
def dump_remote(remote="live")
|
61
61
|
server = Pave::Remote.server(remote)
|
62
62
|
directory = Pave::Remote.directory(remote)
|
63
63
|
db = remote_db
|
64
|
-
say "Remotely creating dump of #{db['name']} at #{server}:#{directory}/db/#{dump_file}"
|
65
|
-
sh "ssh #{server} \"cd #{directory}/db; mysqldump -u#{db['user']} -p#{db['pass']} #{db['name']} | gzip > #{dump_file}\""
|
64
|
+
say "Remotely creating dump of #{db['name']} at #{server}:#{directory}/db/#{dump_file(:remote)}"
|
65
|
+
sh "ssh #{server} \"cd #{directory}/db; mysqldump -u#{db['user']} -p#{db['pass']} #{db['name']} | gzip > #{dump_file(:remote)}\""
|
66
66
|
end
|
67
67
|
|
68
68
|
def execute
|
69
|
-
say "Executing #{dump_file} on #{name}"
|
70
|
-
sh "gzip -dc ./db/#{dump_file} | mysql -uroot #{name}"
|
69
|
+
say "Executing #{dump_file(:local)} on #{name}"
|
70
|
+
sh "gzip -dc ./db/#{dump_file(:local)} | mysql -uroot #{name}"
|
71
71
|
end
|
72
72
|
|
73
73
|
def execute_remote(remote="live")
|
74
74
|
server = Pave::Remote.server(remote)
|
75
75
|
directory = Pave::Remote.directory(remote)
|
76
76
|
db = remote_db
|
77
|
-
say "Remotely executing #{dump_file} on live #{db['name']}"
|
78
|
-
sh "ssh #{server} \"cd #{directory}/db; gzip -dc #{dump_file} | mysql -u#{db['user']} -p#{db['pass']} #{db['name']}\""
|
77
|
+
say "Remotely executing #{dump_file(:remote)} on live #{db['name']}"
|
78
|
+
sh "ssh #{server} \"cd #{directory}/db; gzip -dc #{dump_file(:remote)} | mysql -u#{db['user']} -p#{db['pass']} #{db['name']}\""
|
79
79
|
end
|
80
80
|
|
81
81
|
def upload(remote="live")
|
82
82
|
# Upload the project's local database dump to remotes db directory.
|
83
|
-
say "Uploading SQL dump to #{remote_url}/db/#{dump_file}"
|
84
|
-
sh "scp ./db/#{dump_file} #{remote_url}/db"
|
83
|
+
say "Uploading ./db/#{dump_file(:local)} SQL dump to #{remote_url}/db/#{dump_file(:remote)}"
|
84
|
+
sh "scp ./db/#{dump_file(:local)} #{remote_url}/db/#{dump_file(:remote)}"
|
85
85
|
end
|
86
86
|
|
87
87
|
def download(remote="live")
|
88
88
|
# Download the project's live database dump to local db directory.
|
89
|
-
say "Downloading SQL dump from #{remote_url}/db/#{dump_file}"
|
90
|
-
sh "scp #{remote_url}/db/#{dump_file} ./db"
|
89
|
+
say "Downloading SQL dump from #{remote_url}/db/#{dump_file(:remote)} to ./db/#{dump_file(:local)}"
|
90
|
+
sh "scp #{remote_url}/db/#{dump_file(:remote)} ./db/#{dump_file(:local)}"
|
91
91
|
end
|
92
92
|
|
93
93
|
def push(remote="live")
|
94
94
|
# Upload the project's local database and replace the live database.
|
95
95
|
dump
|
96
|
+
dump_remote(remote) # for backup purposes
|
96
97
|
upload(remote)
|
97
98
|
execute_remote(remote)
|
98
99
|
end
|
99
100
|
|
100
101
|
def pull(remote="live")
|
101
102
|
# Download the project's live database and replace local database.
|
103
|
+
dump # for backup purposes
|
102
104
|
dump_remote(remote)
|
103
105
|
download(remote)
|
104
106
|
execute
|
data/lib/pave/version.rb
CHANGED