db_backups 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,24 +7,66 @@ stored in Rackspace CloudFiles
7
7
  Designed for internal usage for *our* rails apps and their mysql backups,
8
8
  but *could* be driven in a more generic direction if anyone external was interested.
9
9
 
10
- Setup:
10
+ ### Setup:
11
11
 
12
- Locomote only:
12
+ ##### Locomote only:
13
13
  ```bash
14
14
  git clone git@github.com:locomote/config.git ~/.loco_config && ln -s ~/.loco_config/fogrc ~/.fog
15
15
  ```
16
16
 
17
- or for everyone else:
17
+ #### or for everyone else:
18
18
 
19
19
  ```bash
20
20
  echo "default:\n rackspace_username: ${RACKSPACE_USERNAME}\n rackspace_api_key: ${RACKSPACE_API_KEY}" > ~/.fog
21
21
  ```
22
22
 
23
- Usage:
23
+ ### Usage:
24
+
25
+ ##### To load the latest production database to your local dev database:
26
+ ```bash
27
+ bundle exec db_backups load
28
+ ```
29
+ ```
30
+ Loading backup <#DbBackup "foo.production.20130327023959.sql" size=245760> into database foo_development ... DONE
31
+ ```
32
+
33
+ ##### To list all the staging backups:
34
+ ```bash
35
+ bundle exec db_backups -estaging index
36
+ ```
37
+ ```
38
+ +---------+---------------------------+----------------+
39
+ | Db Backups (foo - staging) |
40
+ +---------+---------------------------+----------------+
41
+ | | last_modified | content_length |
42
+ +---------+---------------------------+----------------+
43
+ | 0 | 2013-03-25 05:56:36 +1100 | 245760 |
44
+ | 1 | 2013-03-25 06:16:17 +1100 | 245760 |
45
+ | 2 | 2013-03-25 23:52:12 +1100 | 245760 |
46
+ | 3 | 2013-03-26 12:06:25 +1100 | 245760 |
47
+ | 4 | 2013-03-27 02:39:59 +1100 | 245760 |
48
+ +---------+---------------------------+----------------+
49
+ ```
50
+
51
+ ##### To get the backup "2" in the staging list:
24
52
  ```bash
25
- db_backups index
26
- db_backups show
27
- db_backups get
28
- db_backups load
29
- db_backups -euat index # NB. defaults to production environment, but can be set to any in the config/database.yml
53
+ bundle exec db_backups -estaging get 2
54
+ ```
55
+ (NB. this cats the sql file. ie. handy for piping to another command, but if you want a copy of it use `retreive` ...)
56
+
57
+ ##### To actually retrieve the backup "1" in the staging list:
58
+ ```bash
59
+ bundle exec db_backups -estaging retrieve 1
60
+ ```
30
61
  ```
62
+ Retrieving backup foo.staging.20130325061617.sql ... DONE
63
+ ```
64
+ (ie. retrieve and save the backup file to disk)
65
+
66
+ ##### To load the latest uat database into staging:
67
+ ```
68
+ ssh foo-staging 'cd foo/current; APP_ENV=staging bundle exec db_backups -euat load'
69
+ ```
70
+ (ie. make sure to set the `APP_ENV` env var correctly)
71
+
72
+ NB. The `retrieve`, `get` and `load` commands all take the `index number` as an argument, but default to the last one if no argument is given.
data/bin/db_backups CHANGED
@@ -32,7 +32,7 @@ class DbBackups::CLI < Optitron::CLI
32
32
  def load(i_int=-1)
33
33
  backup = container[i_int]
34
34
  print "Loading backup #{backup.inspect} into database #{database} ... "
35
- p cmd = "mysql -u#{username} -p#{password} #{database}"
35
+ cmd = "mysql -u#{username} -p#{password} #{database}"
36
36
  Open3.popen3(cmd) do |stdin, stdout, stderr|
37
37
  stdin.write(cat(backup))
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module DbBackups
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_backups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: 1412823359237109529
111
+ hash: 2596256218288951291
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: 1412823359237109529
120
+ hash: 2596256218288951291
121
121
  requirements: []
122
122
  rubyforge_project:
123
123
  rubygems_version: 1.8.24