db2fog 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +2 -0
- data/README.rdoc +20 -0
- data/lib/db2fog.rb +16 -4
- metadata +52 -17
data/HISTORY
CHANGED
data/README.rdoc
CHANGED
@@ -88,6 +88,26 @@ do this:
|
|
88
88
|
DB2Fog.new.backup
|
89
89
|
DB2Fog.new.clean
|
90
90
|
|
91
|
+
=== Restoring the production DB to development
|
92
|
+
|
93
|
+
It might be useful to give developers a quick way to restore a production
|
94
|
+
backup to their local machines. Create a rake task like so:
|
95
|
+
|
96
|
+
|
97
|
+
namespace :db do
|
98
|
+
task :restore => :environment do
|
99
|
+
DB2Fog.new.restore("production_db_name")
|
100
|
+
end
|
101
|
+
|
102
|
+
namespace :production do
|
103
|
+
task :pull => ["db:drop", "db:create", "db:restore", "db:migrate"]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
.. and then run
|
108
|
+
|
109
|
+
bundle exec rake db:production:pull
|
110
|
+
|
91
111
|
== Compatibility
|
92
112
|
|
93
113
|
This is pure so ruby should run on most ruby VMs. I develop on MRI 1.9.2.
|
data/lib/db2fog.rb
CHANGED
@@ -16,8 +16,19 @@ class DB2Fog
|
|
16
16
|
store.store(most_recent_dump_file_name, file_name)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# download the latest backup and restore it to the current database.
|
20
|
+
#
|
21
|
+
# **** CAUTION **** The database for the current RAILS_ENV will be emptied
|
22
|
+
# and all tables will be recreated.
|
23
|
+
#
|
24
|
+
# The database you're restoring from and restoring to may have a different
|
25
|
+
# names (ie. restoring mydb_production into mydb_development). If that's
|
26
|
+
# the case, you should provide the source database name (ie. mydb_production)
|
27
|
+
# as an argument.
|
28
|
+
#
|
29
|
+
def restore(source_database_name = nil)
|
30
|
+
most_recent_file_name = most_recent_dump_file_name(source_database_name)
|
31
|
+
dump_file_name = store.fetch(most_recent_file_name).read
|
21
32
|
file = store.fetch(dump_file_name)
|
22
33
|
database.restore(file.path)
|
23
34
|
end
|
@@ -61,8 +72,9 @@ class DB2Fog
|
|
61
72
|
@store ||= FogStore.new
|
62
73
|
end
|
63
74
|
|
64
|
-
def most_recent_dump_file_name
|
65
|
-
|
75
|
+
def most_recent_dump_file_name(database_name = nil)
|
76
|
+
database_name ||= db_credentials[:database]
|
77
|
+
"most-recent-dump-#{database_name}.txt"
|
66
78
|
end
|
67
79
|
|
68
80
|
def db_credentials
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db2fog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: activerecord
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '3.0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: fog
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '1.0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rake
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: mysql2
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: rspec
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ~>
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '2.6'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.6'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: timecop
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ~>
|
@@ -87,7 +117,12 @@ dependencies:
|
|
87
117
|
version: 0.3.5
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.3.5
|
91
126
|
description: db2fog provides rake tasks for backing up and restoring your DB to cloud
|
92
127
|
storage providers
|
93
128
|
email:
|
@@ -124,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
159
|
version: 1.3.2
|
125
160
|
requirements: []
|
126
161
|
rubyforge_project:
|
127
|
-
rubygems_version: 1.8.
|
162
|
+
rubygems_version: 1.8.23
|
128
163
|
signing_key:
|
129
164
|
specification_version: 3
|
130
165
|
summary: db2fog provides rake tasks for backing up and restoring your DB to cloud
|