astrails-safe 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/CHANGELOG +25 -0
- data/Gemfile +4 -0
- data/{LICENSE → LICENSE.txt} +3 -1
- data/README.markdown +109 -114
- data/Rakefile +5 -55
- data/TODO +11 -0
- data/astrails-safe.gemspec +35 -0
- data/lib/astrails/safe.rb +4 -4
- data/lib/astrails/safe/archive.rb +2 -2
- data/lib/astrails/safe/cloudfiles.rb +16 -3
- data/lib/astrails/safe/config/node.rb +1 -1
- data/lib/astrails/safe/local.rb +3 -0
- data/lib/astrails/safe/mysqldump.rb +1 -1
- data/lib/astrails/safe/pipe.rb +4 -0
- data/lib/astrails/safe/s3.rb +10 -2
- data/lib/astrails/safe/sink.rb +2 -0
- data/lib/astrails/safe/source.rb +1 -0
- data/lib/astrails/safe/stream.rb +1 -0
- data/lib/astrails/safe/version.rb +5 -0
- data/{examples/integration/archive_integration_example.rb → spec/integration/archive_integration_spec.rb} +1 -2
- data/{examples/integration/cleanup_example.rb → spec/integration/cleanup_spec.rb} +2 -3
- data/spec/spec_helper.rb +7 -0
- data/{examples/unit/archive_example.rb → spec/unit/archive_spec.rb} +1 -1
- data/spec/unit/cloudfiles_spec.rb +177 -0
- data/{examples/unit/config_example.rb → spec/unit/config_spec.rb} +1 -1
- data/{examples/unit/gpg_example.rb → spec/unit/gpg_spec.rb} +2 -2
- data/{examples/unit/gzip_example.rb → spec/unit/gzip_spec.rb} +6 -6
- data/{examples/unit/local_example.rb → spec/unit/local_spec.rb} +2 -2
- data/{examples/unit/mysqldump_example.rb → spec/unit/mysqldump_spec.rb} +2 -2
- data/{examples/unit/pgdump_example.rb → spec/unit/pgdump_spec.rb} +2 -2
- data/{examples/unit/s3_example.rb → spec/unit/s3_spec.rb} +13 -5
- data/{examples/unit/svndump_example.rb → spec/unit/svndump_spec.rb} +2 -2
- data/templates/script.rb +1 -1
- metadata +186 -91
- data/VERSION.yml +0 -4
- data/examples/example_helper.rb +0 -19
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
0.2.8
|
2
|
+
|
3
|
+
* ruby 1.9.2 compatibility (tests mostly)
|
4
|
+
* code review, and tons of small fixes
|
5
|
+
* check file size before attempting to upload to cloudfiles
|
6
|
+
* testing framework changed from micronaut to rspec
|
7
|
+
|
8
|
+
0.2.7
|
9
|
+
|
10
|
+
* default options for gpg now include '--no-use-agent'
|
11
|
+
* support for 'command' option for gpg
|
12
|
+
* quote values in mysql password file
|
13
|
+
* add 'lib' to $:
|
14
|
+
* [EXPERIMENTAL] Rackspace Cloud Files support
|
15
|
+
|
16
|
+
0.2.6
|
17
|
+
|
18
|
+
* fix typo in the template config file. (change option to options in pgdump)
|
19
|
+
* add example 'options' for tar in the template config file.
|
20
|
+
* do not try to upload more then 5G of data to S3. print error instead
|
21
|
+
|
22
|
+
0.2.5
|
23
|
+
|
24
|
+
* Safety mesure: Disable overwrite of existing configuration keys except for multi-value keys
|
25
|
+
supported multi-value keys: skip_tables, exclude, files
|
data/Gemfile
ADDED
data/{LICENSE → LICENSE.txt}
RENAMED
data/README.markdown
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
astrails-safe
|
2
|
-
=============
|
1
|
+
# astrails-safe
|
3
2
|
|
4
3
|
Simple database and filesystem backups with S3 and Rackspace Cloud Files support (with optional encryption)
|
5
4
|
|
6
|
-
Home: http://
|
5
|
+
* Home: [http://astrails.com/opensource/astrails-safe](http://astrails.com/opensource/astrails-safe)
|
6
|
+
* Code: [http://github.com/astrails/safe](http://github.com/astrails/safe)
|
7
|
+
* Blog: [http://blog.astrails.com/astrails-safe](http://blog.astrails.com/astrails-safe)
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
[![Code Climate](https://codeclimate.com/github/astrails/safe.png)](https://codeclimate.com/github/astrails/safe)
|
10
|
+
|
11
|
+
## Motivation
|
10
12
|
|
11
13
|
We needed a backup solution that will satisfy the following requirements:
|
12
14
|
|
@@ -20,12 +22,11 @@ We needed a backup solution that will satisfy the following requirements:
|
|
20
22
|
|
21
23
|
And since we didn't find any, we wrote our own :)
|
22
24
|
|
23
|
-
Contributions
|
24
|
-
-------------
|
25
|
+
## Contributions
|
25
26
|
|
26
27
|
The following functionality was contributed by astrails-safe users:
|
27
28
|
|
28
|
-
* PostgreSQL dump using pg_dump (by Mark Mansour <mark@stateofflux.com>)
|
29
|
+
* PostgreSQL dump using `pg_dump` (by Mark Mansour <mark@stateofflux.com>)
|
29
30
|
* Subversion dump using svndump (by Richard Luther <richard.luther@gmail.com>)
|
30
31
|
* SFTP remote storage (by Adam <adam@mediadrive.ca>)
|
31
32
|
* benchmarking output (By Neer)
|
@@ -36,18 +37,15 @@ The following functionality was contributed by astrails-safe users:
|
|
36
37
|
|
37
38
|
Thanks to all :)
|
38
39
|
|
39
|
-
Installation
|
40
|
-
------------
|
40
|
+
## Installation
|
41
41
|
|
42
42
|
sudo gem install astrails-safe --source http://gemcutter.org
|
43
43
|
|
44
|
-
Reporting problems
|
45
|
-
------------------
|
44
|
+
## Reporting problems
|
46
45
|
|
47
46
|
Please report problems at the [Issues tracker](http://github.com/astrails/safe/issues)
|
48
47
|
|
49
|
-
Usage
|
50
|
-
-----
|
48
|
+
## Usage
|
51
49
|
|
52
50
|
Usage:
|
53
51
|
astrails-safe [OPTIONS] CONFIG_FILE
|
@@ -57,10 +55,9 @@ Usage
|
|
57
55
|
-n, --dry-run just pretend, don't do anything.
|
58
56
|
-L, --local skip remote storage, only do local backups
|
59
57
|
|
60
|
-
Note:
|
58
|
+
Note: CONFIG\_FILE will be created from template if missing
|
61
59
|
|
62
|
-
Encryption
|
63
|
-
----------
|
60
|
+
## Encryption
|
64
61
|
|
65
62
|
If you want to encrypt your backups you have 2 options:
|
66
63
|
* use simple password encryption
|
@@ -92,24 +89,23 @@ The procedure to create and transfer the key is as follows:
|
|
92
89
|
(you can accept all the defaults).
|
93
90
|
|
94
91
|
2. extract your public key into a file (assuming you used test@example.com as your key email):
|
95
|
-
gpg -a --export test@example.com > test@example.com.pub
|
92
|
+
`gpg -a --export test@example.com > test@example.com.pub`
|
96
93
|
|
97
94
|
3. transfer public key to the server
|
98
|
-
scp test@example.com.pub root@example.com
|
95
|
+
`scp test@example.com.pub root@example.com:`
|
99
96
|
|
100
97
|
4. import public key on the remote system:
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
</pre>
|
98
|
+
|
99
|
+
$ gpg --import test@example.com.pub
|
100
|
+
gpg: key 45CA9403: public key "Test Backup <test@example.com>" imported
|
101
|
+
gpg: Total number processed: 1
|
102
|
+
gpg: imported: 1
|
107
103
|
|
108
104
|
5. since we don't keep the secret part of the key on the remote server, gpg has
|
109
105
|
no way to know its yours and can be trusted.
|
110
106
|
To fix that we can sign it with other trusted key, or just directly modify its
|
111
107
|
trust level in gpg (use level 5):
|
112
|
-
|
108
|
+
|
113
109
|
$ gpg --edit-key test@example.com
|
114
110
|
...
|
115
111
|
Command> trust
|
@@ -124,119 +120,118 @@ The procedure to create and transfer the key is as follows:
|
|
124
120
|
Your decision? 5
|
125
121
|
...
|
126
122
|
Command> quit
|
127
|
-
</pre>
|
128
123
|
|
129
124
|
6. export your secret key for backup
|
130
125
|
(we recommend to print it on paper and burn to a CD/DVD and store in a safe place):
|
131
|
-
<pre>
|
132
|
-
$ gpg -a --export-secret-key test@example.com > test@example.com.key
|
133
|
-
</pre>
|
134
|
-
|
135
|
-
|
136
|
-
Example configuration
|
137
|
-
---------------------
|
138
|
-
<pre>
|
139
|
-
safe do
|
140
|
-
local :path => "/backup/:kind/:id"
|
141
|
-
|
142
|
-
s3 do
|
143
|
-
key "...................."
|
144
|
-
secret "........................................"
|
145
|
-
bucket "backup.astrails.com"
|
146
|
-
path "servers/alpha/:kind/:id"
|
147
|
-
end
|
148
126
|
|
149
|
-
|
150
|
-
username "..........."
|
151
|
-
api_key "................................."
|
152
|
-
container "safe_backup"
|
153
|
-
path ":kind/" # this is default
|
154
|
-
service_net false
|
155
|
-
end
|
127
|
+
$ gpg -a --export-secret-key test@example.com > test@example.com.key
|
156
128
|
|
157
|
-
sftp do
|
158
|
-
host "sftp.astrails.com"
|
159
|
-
user "astrails"
|
160
|
-
# port 8023
|
161
|
-
password "ssh password for sftp"
|
162
|
-
end
|
163
129
|
|
164
|
-
gpg do
|
165
|
-
command "/usr/local/bin/gpg"
|
166
|
-
options "--no-use-agent"
|
167
|
-
# symmetric encryption key
|
168
|
-
# password "qwe"
|
169
130
|
|
170
|
-
|
171
|
-
key "backup@astrails.com"
|
172
|
-
end
|
131
|
+
## Example configuration
|
173
132
|
|
174
|
-
|
175
|
-
local
|
176
|
-
s3 100
|
177
|
-
cloudfiles 100
|
178
|
-
sftp 100
|
179
|
-
end
|
133
|
+
safe do
|
134
|
+
local :path => "/backup/:kind/:id"
|
180
135
|
|
181
|
-
|
182
|
-
|
136
|
+
s3 do
|
137
|
+
key "...................."
|
138
|
+
secret "........................................"
|
139
|
+
bucket "backup.astrails.com"
|
140
|
+
path "servers/alpha/:kind/:id"
|
141
|
+
end
|
183
142
|
|
184
|
-
|
185
|
-
|
186
|
-
|
143
|
+
cloudfiles do
|
144
|
+
user "..........."
|
145
|
+
api_key "................................."
|
146
|
+
container "safe_backup"
|
147
|
+
path ":kind/" # this is default
|
148
|
+
service_net false
|
149
|
+
end
|
187
150
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
skip_tables ["bar", "baz"]
|
151
|
+
sftp do
|
152
|
+
host "sftp.astrails.com"
|
153
|
+
user "astrails"
|
154
|
+
# port 8023
|
155
|
+
password "ssh password for sftp"
|
194
156
|
end
|
195
157
|
|
196
|
-
|
158
|
+
gpg do
|
159
|
+
command "/usr/local/bin/gpg"
|
160
|
+
options "--no-use-agent"
|
161
|
+
# symmetric encryption key
|
162
|
+
# password "qwe"
|
197
163
|
|
198
|
-
|
199
|
-
|
200
|
-
repo_path "/home/svn/my_repo"
|
164
|
+
# public GPG key (must be known to GPG, i.e. be on the keyring)
|
165
|
+
key "backup@astrails.com"
|
201
166
|
end
|
202
|
-
end
|
203
167
|
|
204
|
-
|
205
|
-
|
168
|
+
keep do
|
169
|
+
local 20
|
170
|
+
s3 100
|
171
|
+
cloudfiles 100
|
172
|
+
sftp 100
|
173
|
+
end
|
206
174
|
|
207
|
-
|
208
|
-
|
175
|
+
mysqldump do
|
176
|
+
options "-ceKq --single-transaction --create-options"
|
209
177
|
|
210
|
-
|
211
|
-
|
212
|
-
|
178
|
+
user "root"
|
179
|
+
password "............"
|
180
|
+
socket "/var/run/mysqld/mysqld.sock"
|
181
|
+
|
182
|
+
database :blog
|
183
|
+
database :servershape
|
184
|
+
database :astrails_com
|
185
|
+
database :secret_project_com do
|
186
|
+
skip_tables "foo"
|
187
|
+
skip_tables ["bar", "baz"]
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
svndump do
|
193
|
+
repo :my_repo do
|
194
|
+
repo_path "/home/svn/my_repo"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
pgdump do
|
199
|
+
options "-i -x -O" # -i => ignore version, -x => do not dump privileges (grant/revoke), -O => skip restoration of object ownership in plain text format
|
213
200
|
|
214
|
-
|
215
|
-
|
216
|
-
archive "git-repositories", :files => "/home/git/repositories"
|
217
|
-
archive "dot-configs", :files => "/home/*/.[^.]*"
|
218
|
-
archive "etc", :files => "/etc", :exclude => "/etc/puppet/other"
|
201
|
+
user "username"
|
202
|
+
password "............" # shouldn't be used, instead setup ident. Current functionality exports a password env to the shell which pg_dump uses - untested!
|
219
203
|
|
220
|
-
|
221
|
-
|
222
|
-
exclude "/var/www/blog.astrails.com/log"
|
223
|
-
exclude "/var/www/blog.astrails.com/tmp"
|
204
|
+
database :blog
|
205
|
+
database :stateofflux_com
|
224
206
|
end
|
225
207
|
|
226
|
-
|
227
|
-
|
228
|
-
|
208
|
+
tar do
|
209
|
+
options "-h" # dereference symlinks
|
210
|
+
archive "git-repositories", :files => "/home/git/repositories"
|
211
|
+
archive "dot-configs", :files => "/home/*/.[^.]*"
|
212
|
+
archive "etc", :files => "/etc", :exclude => "/etc/puppet/other"
|
213
|
+
|
214
|
+
archive "blog-astrails-com" do
|
215
|
+
files "/var/www/blog.astrails.com/"
|
216
|
+
exclude "/var/www/blog.astrails.com/log"
|
217
|
+
exclude "/var/www/blog.astrails.com/tmp"
|
218
|
+
end
|
219
|
+
|
220
|
+
archive "astrails-com" do
|
221
|
+
files "/var/www/astrails.com/"
|
222
|
+
exclude ["/var/www/astrails.com/log", "/var/www/astrails.com/tmp"]
|
223
|
+
end
|
229
224
|
end
|
230
225
|
end
|
231
|
-
end
|
232
|
-
</pre>
|
233
226
|
|
234
|
-
|
235
|
-
------------------
|
227
|
+
## Contributing
|
236
228
|
|
237
|
-
|
229
|
+
1. Fork it
|
230
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
231
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
232
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
233
|
+
5. Create new Pull Request
|
238
234
|
|
239
|
-
Copyright
|
240
|
-
---------
|
235
|
+
## Copyright
|
241
236
|
|
242
|
-
Copyright (c)
|
237
|
+
Copyright (c) 2010 Astrails Ltd. See LICENSE.txt for details.
|
data/Rakefile
CHANGED
@@ -1,58 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require 'rake'
|
1
|
+
require "bundler/gem_tasks"
|
3
2
|
|
4
|
-
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "astrails-safe"
|
8
|
-
gem.summary = %Q{Backup filesystem and databases (MySQL and PostgreSQL) locally or to a remote server/service (with encryption)}
|
9
|
-
gem.description = <<-DESC
|
10
|
-
Astrails-Safe is a simple tool to backup databases (MySQL and PostgreSQL), Subversion repositories (with svndump) and just files.
|
11
|
-
Backups can be stored locally or remotely and can be enctypted.
|
12
|
-
Remote storage is supported on Amazon S3, Rackspace Cloud Files, or just plain SFTP.
|
13
|
-
DESC
|
14
|
-
gem.email = "we@astrails.com"
|
15
|
-
gem.homepage = "http://blog.astrails.com/astrails-safe"
|
16
|
-
gem.authors = ["Astrails Ltd."]
|
17
|
-
gem.files = FileList["[A-Z]*.*", "{bin,examples,generators,lib,rails,spec,test,templates}/**/*", 'Rakefile', 'LICENSE*']
|
3
|
+
require 'rspec/core/rake_task'
|
18
4
|
|
19
|
-
|
20
|
-
|
21
|
-
gem.add_dependency("net-sftp")
|
22
|
-
|
23
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
24
|
-
end
|
25
|
-
rescue LoadError
|
26
|
-
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
27
|
-
end
|
28
|
-
|
29
|
-
require 'micronaut/rake_task'
|
30
|
-
Micronaut::RakeTask.new(:examples) do |examples|
|
31
|
-
examples.pattern = 'examples/**/*_example.rb'
|
32
|
-
examples.ruby_opts << '-Ilib -Iexamples'
|
33
|
-
end
|
34
|
-
|
35
|
-
Micronaut::RakeTask.new(:rcov) do |examples|
|
36
|
-
examples.pattern = 'examples/**/*_example.rb'
|
37
|
-
examples.rcov_opts = '-Ilib -Iexamples -iastrails -x\/gems\/'
|
38
|
-
examples.rcov = true
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
task :default => :examples
|
43
|
-
|
44
|
-
require 'rake/rdoctask'
|
45
|
-
Rake::RDocTask.new do |rdoc|
|
46
|
-
if File.exist?('VERSION.yml')
|
47
|
-
config = YAML.load(File.read('VERSION.yml'))
|
48
|
-
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
49
|
-
else
|
50
|
-
version = ""
|
51
|
-
end
|
52
|
-
|
53
|
-
rdoc.rdoc_dir = 'rdoc'
|
54
|
-
rdoc.title = "safe #{version}"
|
55
|
-
rdoc.rdoc_files.include('README*')
|
56
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
-
end
|
5
|
+
desc "run specs"
|
6
|
+
RSpec::Core::RakeTask.new
|
58
7
|
|
8
|
+
task default: :spec
|
data/TODO
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
- add 'silent'
|
2
|
+
- handle errors from mysqldump
|
3
|
+
- check that gpg is installed
|
4
|
+
- support percona XtraBackup as an option instead of mysqldump [patches anyone :) ?]
|
5
|
+
- backup validation:
|
6
|
+
- support for 'minsize' opition in backup that will check that produced backup is at least the expected size
|
7
|
+
this should catch many backup failure scenarious (like broken mysql connection, insufficient disk space etc.
|
8
|
+
- support differencial backups
|
9
|
+
- it should be fairly easy for filesystem backups using tar's built in incremental functionality.
|
10
|
+
- for mysql need to use XtraBackup
|
11
|
+
- or we can keep the previous dump locally and store only diff with the latest dump
|