outback 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/VERSION +1 -1
- data/lib/outback/directory_source.rb +3 -2
- data/lib/outback/directory_target.rb +1 -1
- data/lib/outback/mysql_source.rb +1 -0
- data/lib/outback/s3_target.rb +9 -3
- data/lib/outback/support/configurable.rb +2 -4
- metadata +10 -10
- data/README +0 -112
data/CHANGELOG
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
@@ -23,10 +23,11 @@ module Outback
|
|
23
23
|
archive_name = Pathname.new(tmpdir).join("#{backup_name}_#{timestamp}_#{source_name}.tar.gz")
|
24
24
|
exclude_list = Pathname.new(tmpdir).join('exclude_list.txt')
|
25
25
|
File.open(exclude_list, 'w') { |f| f << excludes.join("\n") }
|
26
|
-
commandline = "tar --create --file #{archive_name} --preserve-permissions --gzip --exclude-from #{exclude_list} #{source_dir}"
|
26
|
+
commandline = "tar --create --file #{archive_name} --preserve-permissions --gzip --exclude-from #{exclude_list} --directory / #{source_dir.to_s.sub(/\A\//, '')}"
|
27
27
|
Outback.debug "executing command: #{commandline}"
|
28
28
|
result = `#{commandline}`
|
29
|
-
|
29
|
+
Outback.debug "result: #{result}"
|
30
|
+
Outback.info "archived directory #{path}"
|
30
31
|
[TempArchive.new(archive_name, self)]
|
31
32
|
end
|
32
33
|
end
|
@@ -33,7 +33,7 @@ module Outback
|
|
33
33
|
end
|
34
34
|
size += archived_file.size
|
35
35
|
end
|
36
|
-
Outback.
|
36
|
+
Outback.info "#{move ? 'Moved' : 'Copied'} #{archives.size} archives (#{size} bytes) to directory #{path}"
|
37
37
|
end
|
38
38
|
|
39
39
|
def list_archives(name)
|
data/lib/outback/mysql_source.rb
CHANGED
@@ -41,6 +41,7 @@ module Outback
|
|
41
41
|
commandline = "mysqldump --defaults-extra-file=#{mysql_conf_file} --opt --user=#{user} --host=#{mysql_host} --port=#{mysql_port} #{database} | gzip > #{archive_name}"
|
42
42
|
result = `#{commandline}`.strip
|
43
43
|
Outback.debug(result) unless result.blank?
|
44
|
+
Outback.info "archived database #{database}"
|
44
45
|
TempArchive.new(archive_name, self).tap { |archive| Outback.debug "dumped #{archive.filename.basename} with #{archive.size} bytes" }
|
45
46
|
end
|
46
47
|
end
|
data/lib/outback/s3_target.rb
CHANGED
@@ -13,14 +13,20 @@ module Outback
|
|
13
13
|
|
14
14
|
def put(archives)
|
15
15
|
connect
|
16
|
+
size, count = 0, 0
|
16
17
|
archives.each do |archive|
|
17
18
|
object_name = [prefix.to_s, archive.filename.basename.to_s].join('/')
|
18
19
|
Outback.debug "S3Target: storing #{archive.filename} in s3://#{bucket}/#{object_name}"
|
19
20
|
AWS::S3::S3Object.store object_name, archive.open, bucket
|
20
|
-
|
21
|
-
|
21
|
+
if AWS::S3::S3Object.exists?(object_name, bucket)
|
22
|
+
size += archive.size
|
23
|
+
count += 1
|
24
|
+
else
|
25
|
+
Outback.error "S3 archive upload failed: #{object_name}"
|
26
|
+
end
|
22
27
|
end
|
23
|
-
Outback.debug "Uploaded #{
|
28
|
+
Outback.debug "Uploaded #{size} bytes to S3"
|
29
|
+
Outback.info "Uploaded #{count} archives (#{size} bytes) to bucket s3://#{bucket}"
|
24
30
|
end
|
25
31
|
|
26
32
|
def list_archives(name)
|
@@ -3,6 +3,8 @@ module Outback
|
|
3
3
|
|
4
4
|
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
6
|
+
base.class_attribute :attributes
|
7
|
+
base.attributes = []
|
6
8
|
end
|
7
9
|
|
8
10
|
module ClassMethods
|
@@ -19,10 +21,6 @@ module Outback
|
|
19
21
|
names.each { |name| attr_reader name }
|
20
22
|
end
|
21
23
|
|
22
|
-
def attributes
|
23
|
-
read_inheritable_attribute(:attributes) || write_inheritable_attribute(:attributes, [])
|
24
|
-
end
|
25
|
-
|
26
24
|
end
|
27
25
|
|
28
26
|
def attr_setter
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthias Grosser
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-03-12 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -41,16 +41,16 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
44
|
+
hash: 7
|
45
45
|
segments:
|
46
|
-
-
|
47
|
-
- 1
|
46
|
+
- 3
|
48
47
|
- 0
|
49
|
-
|
48
|
+
- 0
|
49
|
+
version: 3.0.0
|
50
50
|
type: :runtime
|
51
51
|
version_requirements: *id002
|
52
52
|
description: A Ruby backup tool
|
53
|
-
email:
|
53
|
+
email: admin@onrooby.com
|
54
54
|
executables:
|
55
55
|
- outback
|
56
56
|
extensions: []
|
@@ -85,7 +85,7 @@ files:
|
|
85
85
|
- bin/outback
|
86
86
|
- MIT-LICENSE
|
87
87
|
- VERSION
|
88
|
-
-
|
88
|
+
- CHANGELOG
|
89
89
|
has_rdoc: true
|
90
90
|
homepage: http://rubygems.org/gems/outback
|
91
91
|
licenses: []
|
data/README
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
== Welcome to Outback
|
2
|
-
|
3
|
-
Outback is a Ruby backup tool, enabling you to create backups of
|
4
|
-
your server files and databases and storing them in a local or
|
5
|
-
remote repository.
|
6
|
-
|
7
|
-
Using a simple DSL, you can specify multiple sources that generate
|
8
|
-
backup data, as well as multiple targets, where backups are going
|
9
|
-
to be stored.
|
10
|
-
|
11
|
-
Outback configuration files are pure Ruby, so writing dynamic
|
12
|
-
configurations or even customized backup sources and targets is a
|
13
|
-
piece of cake.
|
14
|
-
|
15
|
-
|
16
|
-
== A simple configuration example
|
17
|
-
|
18
|
-
# You can instantiate as many configurations as you like
|
19
|
-
# Outback will enqueue and execute all configurations that were
|
20
|
-
# instantiated during a single run.
|
21
|
-
|
22
|
-
Outback::Configuration.new 'name' do
|
23
|
-
source :directory, '/ver/www' do
|
24
|
-
exclude '/var/www/foo'
|
25
|
-
exclude '/var/www/icons/*.png'
|
26
|
-
end
|
27
|
-
|
28
|
-
source :mysql do
|
29
|
-
user 'mysqlusername'
|
30
|
-
password 'mysqlpassword'
|
31
|
-
host 'localhost'
|
32
|
-
exclude 'mysql', 'information_schema'
|
33
|
-
|
34
|
-
#
|
35
|
-
# If you do not specify a specific database, all databases
|
36
|
-
# will be dumped and included in the backup
|
37
|
-
# database 'specific_database'
|
38
|
-
end
|
39
|
-
|
40
|
-
# Amazon S3 storage
|
41
|
-
target :s3 do
|
42
|
-
access_key 'S3 access key'
|
43
|
-
secret_key 'S3 secret key'
|
44
|
-
bucket 'bucketname'
|
45
|
-
prefix 'backups/daily'
|
46
|
-
|
47
|
-
# Backups will be purged after the time specified here.
|
48
|
-
# Just omit the definition to keep archives forever.
|
49
|
-
ttl 1.month
|
50
|
-
end
|
51
|
-
|
52
|
-
# Store on a local filesystem path
|
53
|
-
target :directory, '/media/backups/daily' do
|
54
|
-
# If you specify the move option, archives will be moved from the temporary
|
55
|
-
# filesystem location in order to speed up things. Otherwise, archives will
|
56
|
-
# be copied. Note that a 'move'-to target must be specified last in the target
|
57
|
-
# chain.
|
58
|
-
move true
|
59
|
-
ttl 1.day
|
60
|
-
user 'root'
|
61
|
-
group 'root'
|
62
|
-
directory_permissions 0700
|
63
|
-
archive_permissions 0600
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
== Default configurations and commandline options
|
69
|
-
|
70
|
-
If you place your backup configurations in the file /etc/outback.conf they
|
71
|
-
will be read automatically when the outback executable is invoked. Make
|
72
|
-
sure to have correct permissions on the configuration files, as they might
|
73
|
-
include database passwords.
|
74
|
-
|
75
|
-
Alternatively, you can pass in the configuration file to read as a
|
76
|
-
commandline argument. The default configuration file in /etc will then be
|
77
|
-
ignored.
|
78
|
-
|
79
|
-
If you have several backup configurations in a single file, say, for daily
|
80
|
-
and monthly backups, you can use the -c commandline option to select the
|
81
|
-
backup to be invoked:
|
82
|
-
|
83
|
-
$ outback -c 'myservername-daily'
|
84
|
-
|
85
|
-
This will run only the backup with the specified name, which enables you to
|
86
|
-
write DRY configurations like this:
|
87
|
-
|
88
|
-
{ :daily => [14.days, 5.days], :monthly => [1.year, 1.year] }.each do |frequency, ttls|
|
89
|
-
s3_ttl, directory_ttl = ttls
|
90
|
-
|
91
|
-
Outback::Configuration.new "yourserver-#{frequency}" do
|
92
|
-
source :directory, '/home'
|
93
|
-
source :directory, '/var/svn'
|
94
|
-
|
95
|
-
target :s3 do
|
96
|
-
access_key 'foo'
|
97
|
-
secret_key 'foo'
|
98
|
-
bucket 'somebucket'
|
99
|
-
prefix "yourserver/#{frequency}"
|
100
|
-
ttl s3_ttl
|
101
|
-
end
|
102
|
-
|
103
|
-
target :directory, "/media/backups/#{frequency}" do
|
104
|
-
move true
|
105
|
-
ttl directory_ttl
|
106
|
-
user 'root'
|
107
|
-
group 'root'
|
108
|
-
directory_permissions 0700
|
109
|
-
archive_permissions 0600
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|