lu-tze 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +23 -9
- data/lib/lu_tze.rb +18 -6
- data/spec/lu_tze_spec.rb +9 -0
- data/spec/spec_helper.rb +0 -0
- metadata +11 -8
data/README.textile
CHANGED
@@ -1,15 +1,29 @@
|
|
1
|
-
h1. Lu
|
1
|
+
h1. Lu Tze
|
2
2
|
|
3
|
-
|
3
|
+
We all know backups are important. However, they're often annoying. So, Lu Tze is a service for automating database backups. It sends an SQL dump of your database off to a remote backup service (Historian). It's been built to work just on Heroku (so PostgreSQL only), although there's potential for it to expand later down the track.
|
4
4
|
|
5
|
-
|
5
|
+
At this point, I've not open-sourced Historian, so while you can look at this side of the code, it's not particularly useful. I'm planning to provide a better overview soon, though.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
h2. Installation and Usage
|
8
|
+
|
9
|
+
Firstly, you'll want to add Lu Tze as a gem requirement - when you're using Bundler (probably with Rails 3), that's a piece of cake with a single line in your Gemfile:
|
10
|
+
|
11
|
+
<pre><code>gem 'lu-tze', '0.2.0', :require => 'lu_tze'</code></pre>
|
12
|
+
|
13
|
+
For those using Rails 2.x, it's slightly more complicated - you need it in both @config/environment.rb@:
|
14
|
+
|
15
|
+
<pre><code>config.gem 'lu-tze', :version => '0.2.0', :lib => 'lu_tze'</code></pre>
|
16
|
+
|
17
|
+
... and then add it to the .gems file that Heroku expects:
|
18
|
+
|
19
|
+
<pre><code>lu-tze --version 0.2.0</code></pre>
|
20
|
+
|
21
|
+
Heroku's free daily cron job is all that's needed to put it all together - I use something like the following in @lib/tasks/cron.rake@:
|
22
|
+
|
23
|
+
<pre><code>task :cron => :environment do
|
24
|
+
LuTze.gather_and_send
|
25
|
+
end</code></pre>
|
12
26
|
|
13
27
|
h2. Copyright
|
14
28
|
|
15
|
-
Copyright (c) 2010 Pat Allan, released under an MIT licence.
|
29
|
+
Copyright (c) 2010 Pat Allan, released under an MIT licence.
|
data/lib/lu_tze.rb
CHANGED
@@ -32,12 +32,24 @@ class LuTze
|
|
32
32
|
|
33
33
|
def dump_command
|
34
34
|
cmd = ""
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
|
36
|
+
if config[:adapter] == 'postgresql'
|
37
|
+
cmd += "echo #{config[:password]} | " if config[:password].present?
|
38
|
+
cmd += "pg_dump --format=p --file=#{file_name}"
|
39
|
+
cmd += " --host=#{config[:host]}" if config[:host].present?
|
40
|
+
cmd += " --port=#{config[:port]}" if config[:port].present?
|
41
|
+
cmd += " --username=#{config[:username]}" if config[:username].present?
|
42
|
+
cmd += " #{config[:database]}"
|
43
|
+
else
|
44
|
+
cmd += "mysqldump --format=p --result-file=#{file_name}"
|
45
|
+
cmd += " --host=#{config[:host]}" if config[:host].present?
|
46
|
+
cmd += " --port=#{config[:port]}" if config[:port].present?
|
47
|
+
cmd += " --user=#{config[:username]}" if config[:username].present?
|
48
|
+
cmd += " --password=#{config[:password]}" if config[:username].present?
|
49
|
+
cmd += " #{config[:database]}"
|
50
|
+
end
|
51
|
+
|
52
|
+
cmd
|
41
53
|
end
|
42
54
|
|
43
55
|
def compress_command
|
data/spec/lu_tze_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lu-tze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Allan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-11 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -92,13 +92,15 @@ files:
|
|
92
92
|
- LICENCE
|
93
93
|
- README.textile
|
94
94
|
- lib/lu_tze.rb
|
95
|
+
- spec/lu_tze_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
95
97
|
has_rdoc: true
|
96
98
|
homepage: http://github.com/freelancing-god/lu-tze
|
97
99
|
licenses: []
|
98
100
|
|
99
101
|
post_install_message:
|
100
|
-
rdoc_options:
|
101
|
-
|
102
|
+
rdoc_options: []
|
103
|
+
|
102
104
|
require_paths:
|
103
105
|
- lib
|
104
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -126,5 +128,6 @@ rubygems_version: 1.3.7
|
|
126
128
|
signing_key:
|
127
129
|
specification_version: 3
|
128
130
|
summary: Sends backups to Historian
|
129
|
-
test_files:
|
130
|
-
|
131
|
+
test_files:
|
132
|
+
- spec/lu_tze_spec.rb
|
133
|
+
- spec/spec_helper.rb
|