astrails-safe 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +132 -0
- data/Rakefile +59 -0
- data/VERSION.yml +4 -0
- metadata +23 -21
- data/README +0 -13
- data/safe.gemspec +0 -37
- data/templates/script.rb +0 -109
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Astrails Ltd.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
= astrails-safe
|
2
|
+
|
3
|
+
Simple mysql and filesystem backups with S3 support (with optional encryption)
|
4
|
+
|
5
|
+
Usage:
|
6
|
+
astrails-safe [OPTIONS] CONFIG_FILE
|
7
|
+
Options:
|
8
|
+
-h, --help This help screen
|
9
|
+
-v, --verbose be verbose, duh!
|
10
|
+
-n, --dry-run just pretend, don't do anything.
|
11
|
+
-L, --local skip S3
|
12
|
+
|
13
|
+
Note: CONFIG_FILE will be created from template if missing
|
14
|
+
|
15
|
+
If you want to encrypt your backups you have 2 options:
|
16
|
+
* use simple password encryption
|
17
|
+
* use GPG public key encryption
|
18
|
+
|
19
|
+
For simple password, just add password entry in gpg section.
|
20
|
+
For public key encryption you will need to create a public/secret keypair.
|
21
|
+
|
22
|
+
We recommend to create your GPG keys only on your local machine and then
|
23
|
+
transfer your public key to the server that will do the backups.
|
24
|
+
|
25
|
+
This way the server will only know how to encrypt the backups but only you
|
26
|
+
will be able to decrypt them using the secret key you have locally. Of course
|
27
|
+
you MUST backup your backup encryption key :)
|
28
|
+
We recommend also pringing the hard paper copy of your GPG key 'just in case'.
|
29
|
+
|
30
|
+
The procedure to create and transfer the key is as follows:
|
31
|
+
|
32
|
+
1. run 'gpg --gen-gen' on your local machine and follow onscreen instructions to create the key
|
33
|
+
(you can accept all the defaults).
|
34
|
+
|
35
|
+
2. extract your public key into a file (assuming you used test@example.com as your key email):
|
36
|
+
gpg -a --export test@example.com > test@example.com.pub
|
37
|
+
|
38
|
+
3. transfer public key to the server
|
39
|
+
scp backup@example.com root@example.com:
|
40
|
+
|
41
|
+
4. import public key on the remote system:
|
42
|
+
$ gpg --import test@example.com.pub
|
43
|
+
gpg: key 45CA9403: public key "Test Backup <test@example.com>" imported
|
44
|
+
gpg: Total number processed: 1
|
45
|
+
gpg: imported: 1
|
46
|
+
|
47
|
+
5. since we don't keep the secret part of the key on the remote server, gpg has
|
48
|
+
no way to know its yours and can be trusted.
|
49
|
+
To fix that we can sign it with other trusted key, or just directly modify its
|
50
|
+
trust level in gpg (use level 5):
|
51
|
+
|
52
|
+
$ gpg --edit-key test@example.com
|
53
|
+
...
|
54
|
+
Command> trust
|
55
|
+
...
|
56
|
+
1 = I don't know or won't say
|
57
|
+
2 = I do NOT trust
|
58
|
+
3 = I trust marginally
|
59
|
+
4 = I trust fully
|
60
|
+
5 = I trust ultimately
|
61
|
+
m = back to the main menu
|
62
|
+
|
63
|
+
Your decision? 5
|
64
|
+
...
|
65
|
+
Command> quit
|
66
|
+
|
67
|
+
6. export your secret key for backup
|
68
|
+
(we recommend to print it on paper and burn to a CD/DVD and store in a safe place):
|
69
|
+
|
70
|
+
gpg -a --export-secret-key test@example.com > test@example.com.key
|
71
|
+
|
72
|
+
|
73
|
+
Example configuration:
|
74
|
+
|
75
|
+
safe do
|
76
|
+
local :path => "/backup/:kind/:id"
|
77
|
+
|
78
|
+
s3 do
|
79
|
+
key "...................."
|
80
|
+
secret "........................................"
|
81
|
+
bucket "backup.astrails.com"
|
82
|
+
path "servers/alpha/:kind/:id"
|
83
|
+
end
|
84
|
+
|
85
|
+
gpg do
|
86
|
+
# symmetric encryption key
|
87
|
+
# password "qwe"
|
88
|
+
|
89
|
+
# public GPG key (must be known to GPG, i.e. be on the keyring)
|
90
|
+
key "backup@astrails.com"
|
91
|
+
end
|
92
|
+
|
93
|
+
keep do
|
94
|
+
local 2
|
95
|
+
s3 2
|
96
|
+
end
|
97
|
+
|
98
|
+
mysqldump do
|
99
|
+
options "-ceKq --single-transaction --create-options"
|
100
|
+
|
101
|
+
user "root"
|
102
|
+
password "............"
|
103
|
+
socket "/var/run/mysqld/mysqld.sock"
|
104
|
+
|
105
|
+
database :blog
|
106
|
+
database :servershape
|
107
|
+
database :astrails_com
|
108
|
+
database :secret_project_com
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
tar do
|
114
|
+
archive "git-repositories", :files => "/home/git/repositories"
|
115
|
+
archive "dot-configs", :files => "/home/*/.[^.]*"
|
116
|
+
archive "etc", :files => "/etc", :exclude => "/etc/puppet/other"
|
117
|
+
|
118
|
+
archive "blog-astrails-com" do
|
119
|
+
files "/var/www/blog.astrails.com/"
|
120
|
+
exclude ["/var/www/blog.astrails.com/log", "/var/www/blog.astrails.com/tmp"]
|
121
|
+
end
|
122
|
+
|
123
|
+
archive "astrails-com" do
|
124
|
+
files "/var/www/astrails.com/"
|
125
|
+
exclude ["/var/www/astrails.com/log", "/var/www/astrails.com/tmp"]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
== Copyright
|
131
|
+
|
132
|
+
Copyright (c) 2009 Astrails Ltd. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "safe"
|
8
|
+
gem.summary = %Q{Backup filesystem and MySQL to Amazon S3 (with encryption)}
|
9
|
+
gem.description = "Simple tool to backup MySQL databases and filesystem locally or to Amazon S3 (with optional encryption)"
|
10
|
+
gem.email = "we@astrails.com"
|
11
|
+
gem.homepage = "http://github.com/astrails/safe"
|
12
|
+
gem.authors = ["Astrails Ltd."]
|
13
|
+
|
14
|
+
gem.add_dependency("aws-s3")
|
15
|
+
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/*_test.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/*_test.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
if File.exist?('VERSION.yml')
|
48
|
+
config = YAML.load(File.read('VERSION.yml'))
|
49
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
50
|
+
else
|
51
|
+
version = ""
|
52
|
+
end
|
53
|
+
|
54
|
+
rdoc.rdoc_dir = 'rdoc'
|
55
|
+
rdoc.title = "safe #{version}"
|
56
|
+
rdoc.rdoc_files.include('README*')
|
57
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
+
end
|
59
|
+
|
data/VERSION.yml
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astrails-safe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Astrails Ltd.
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-04-06 00:00:00 -07:00
|
13
|
+
default_executable: astrails-safe
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-s3
|
@@ -28,33 +28,35 @@ executables:
|
|
28
28
|
- astrails-safe
|
29
29
|
extensions: []
|
30
30
|
|
31
|
-
extra_rdoc_files:
|
32
|
-
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
33
34
|
files:
|
34
|
-
-
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- VERSION.yml
|
35
39
|
- bin/astrails-safe
|
36
|
-
- lib/extensions/mktmpdir.rb
|
37
40
|
- lib/astrails/safe.rb
|
38
|
-
- lib/astrails/safe/
|
39
|
-
- lib/astrails/safe/gpg.rb
|
40
|
-
- lib/astrails/safe/mysqldump.rb
|
41
|
-
- lib/astrails/safe/stream.rb
|
41
|
+
- lib/astrails/safe/archive.rb
|
42
42
|
- lib/astrails/safe/config/builder.rb
|
43
43
|
- lib/astrails/safe/config/node.rb
|
44
|
-
- lib/astrails/safe/
|
44
|
+
- lib/astrails/safe/gpg.rb
|
45
|
+
- lib/astrails/safe/gzip.rb
|
46
|
+
- lib/astrails/safe/local.rb
|
47
|
+
- lib/astrails/safe/mysqldump.rb
|
45
48
|
- lib/astrails/safe/pipe.rb
|
49
|
+
- lib/astrails/safe/s3.rb
|
50
|
+
- lib/astrails/safe/sink.rb
|
46
51
|
- lib/astrails/safe/source.rb
|
47
|
-
- lib/astrails/safe/
|
48
|
-
- lib/astrails/safe/local.rb
|
52
|
+
- lib/astrails/safe/stream.rb
|
49
53
|
- lib/astrails/safe/tmp_file.rb
|
50
|
-
- lib/
|
51
|
-
|
52
|
-
- safe.gemspec
|
53
|
-
has_rdoc: false
|
54
|
+
- lib/extensions/mktmpdir.rb
|
55
|
+
has_rdoc: true
|
54
56
|
homepage: http://github.com/astrails/safe
|
55
57
|
post_install_message:
|
56
|
-
rdoc_options:
|
57
|
-
|
58
|
+
rdoc_options:
|
59
|
+
- --charset=UTF-8
|
58
60
|
require_paths:
|
59
61
|
- lib
|
60
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -75,6 +77,6 @@ rubyforge_project:
|
|
75
77
|
rubygems_version: 1.2.0
|
76
78
|
signing_key:
|
77
79
|
specification_version: 2
|
78
|
-
summary:
|
80
|
+
summary: Backup filesystem and MySQL to Amazon S3 (with encryption)
|
79
81
|
test_files: []
|
80
82
|
|
data/README
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
Simple mysql and filesystem backups with S3 support
|
2
|
-
|
3
|
-
Usage:
|
4
|
-
astrails-safe [OPTIONS] CONFIG_FILE
|
5
|
-
Options:
|
6
|
-
-h, --help This help screen
|
7
|
-
-v, --verbose be verbose, duh!
|
8
|
-
-n, --dry-run just pretend, don't do anything.
|
9
|
-
-L, --local skip S3
|
10
|
-
|
11
|
-
Note: CONFIG_FILE will be created from template if missing
|
12
|
-
|
13
|
-
See template for configuration examples
|
data/safe.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = "safe"
|
3
|
-
s.version = "0.1.1"
|
4
|
-
s.date = "2009-03-15"
|
5
|
-
s.summary = "Astrails Safe"
|
6
|
-
s.email = "we@astrails.com"
|
7
|
-
s.homepage = "http://github.com/astrails/safe"
|
8
|
-
s.description = "Simple tool to backup MySQL databases and filesystem locally or to Amazon S3 (with optional encryption)"
|
9
|
-
s.has_rdoc = false
|
10
|
-
s.authors = ["Astrails Ltd."]
|
11
|
-
s.files = files = %w(
|
12
|
-
README
|
13
|
-
bin/astrails-safe
|
14
|
-
lib/extensions/mktmpdir.rb
|
15
|
-
lib/astrails/safe.rb
|
16
|
-
lib/astrails/safe/s3.rb
|
17
|
-
lib/astrails/safe/gpg.rb
|
18
|
-
lib/astrails/safe/mysqldump.rb
|
19
|
-
lib/astrails/safe/stream.rb
|
20
|
-
lib/astrails/safe/config/builder.rb
|
21
|
-
lib/astrails/safe/config/node.rb
|
22
|
-
lib/astrails/safe/sink.rb
|
23
|
-
lib/astrails/safe/pipe.rb
|
24
|
-
lib/astrails/safe/source.rb
|
25
|
-
lib/astrails/safe/archive.rb
|
26
|
-
lib/astrails/safe/local.rb
|
27
|
-
lib/astrails/safe/tmp_file.rb
|
28
|
-
lib/astrails/safe/gzip.rb
|
29
|
-
templates/script.rb
|
30
|
-
safe.gemspec
|
31
|
-
)
|
32
|
-
s.executables = files.grep(/^bin/).map {|x| x.gsub(/^bin\//, "")}
|
33
|
-
|
34
|
-
s.test_files = []
|
35
|
-
s.add_dependency("aws-s3")
|
36
|
-
end
|
37
|
-
|
data/templates/script.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
safe do
|
2
|
-
|
3
|
-
# backup file path (not including filename)
|
4
|
-
# supported substitutions:
|
5
|
-
# :kind -> backup 'engine' kind, e.g. "mysqldump" or "archive"
|
6
|
-
# :id -> backup 'id', e.g. "blog", "production", etc.
|
7
|
-
# :timestamp -> current run timestamp (same for all the backups in the same 'run')
|
8
|
-
# you can set separate :path for all backups (or once globally here)
|
9
|
-
local do
|
10
|
-
path "/backup/:kind/"
|
11
|
-
end
|
12
|
-
|
13
|
-
## uncomment to enable uploads to Amazon S3
|
14
|
-
## Amazon S3 auth (optional)
|
15
|
-
## don't forget to add :s3 to the 'store' list
|
16
|
-
# s3 do
|
17
|
-
# key YOUR_S3_KEY
|
18
|
-
# secret YOUR_S3_SECRET
|
19
|
-
# bucket S3_BUCKET
|
20
|
-
# # path for uploads to S3. supports same substitution like :local/:path
|
21
|
-
# path ":kind/" # this is default
|
22
|
-
# end
|
23
|
-
|
24
|
-
## alternative style:
|
25
|
-
# s3 :key => YOUR_S3_KEY, :secret => YOUR_S3_SECRET, :bucket => S3_BUCKET
|
26
|
-
|
27
|
-
## uncomment to enable GPG encryption.
|
28
|
-
## Note: you can use public 'key' or symmetric password but not both!
|
29
|
-
# gpg do
|
30
|
-
# # key "backup@astrails.com"
|
31
|
-
# password "astrails"
|
32
|
-
# end
|
33
|
-
|
34
|
-
## uncomment to enable backup rotation. keep only given number of latest
|
35
|
-
## backups. remove the rest
|
36
|
-
# keep do
|
37
|
-
# local 4 # keep 4 local backups
|
38
|
-
# s3 20 # keep 20 S3 backups
|
39
|
-
# end
|
40
|
-
|
41
|
-
# backup mysql databases with mysqldump
|
42
|
-
mysqldump do
|
43
|
-
# you can override any setting from parent in a child:
|
44
|
-
options "-ceKq --single-transaction --create-options"
|
45
|
-
|
46
|
-
user "astrails"
|
47
|
-
password ""
|
48
|
-
# host "localhost"
|
49
|
-
# port 3306
|
50
|
-
socket "/var/run/mysqld/mysqld.sock"
|
51
|
-
|
52
|
-
# database is a 'collection' element. it must have a hash or block parameter
|
53
|
-
# it will be 'collected' in a 'databases', with database id (1st arg) used as hash key
|
54
|
-
# the following code will create mysqldump/databases/blog and mysqldump/databases/mysql ocnfiguration 'nodes'
|
55
|
-
|
56
|
-
# backup database with default values
|
57
|
-
# database :blog
|
58
|
-
|
59
|
-
# backup overriding some values
|
60
|
-
# database :production do
|
61
|
-
# # you can override 'partially'
|
62
|
-
# keep :local => 3
|
63
|
-
# # keep/local is 3, and keep/s3 is 20 (from parent)
|
64
|
-
|
65
|
-
# # local override for gpg password
|
66
|
-
# gpg do
|
67
|
-
# password "custom-production-pass"
|
68
|
-
# end
|
69
|
-
|
70
|
-
# skip_tables [:logger_exceptions, :request_logs] # skip those tables during backup
|
71
|
-
# end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
tar do
|
77
|
-
# 'archive' is a collection item, just like 'database'
|
78
|
-
# archive "git-repositories" do
|
79
|
-
# # files and directories to backup
|
80
|
-
# files "/home/git/repositories"
|
81
|
-
# end
|
82
|
-
|
83
|
-
# archive "etc-files" do
|
84
|
-
# files "/etc"
|
85
|
-
# # exlude those files/directories
|
86
|
-
# exclude "/etc/puppet/other"
|
87
|
-
# end
|
88
|
-
|
89
|
-
# archive "dot-configs" do
|
90
|
-
# files "/home/*/.[^.]*"
|
91
|
-
# end
|
92
|
-
|
93
|
-
# archive "blog" do
|
94
|
-
# files "/var/www/blog.astrails.com/"
|
95
|
-
# # specify multiple files/directories as array
|
96
|
-
# exclude ["/var/www/blog.astrails.com/log", "/var/www/blog.astrails.com/tmp"]
|
97
|
-
# end
|
98
|
-
|
99
|
-
# archive "site" do
|
100
|
-
# files "/var/www/astrails.com/"
|
101
|
-
# exclude ["/var/www/astrails.com/log", "/var/www/astrails.com/tmp"]
|
102
|
-
# end
|
103
|
-
|
104
|
-
# archive :misc do
|
105
|
-
# files [ "/backup/*.rb" ]
|
106
|
-
# end
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|