outback 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,112 @@
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
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -36,7 +36,7 @@ module Outback
36
36
  end
37
37
 
38
38
  def purge_targets
39
- targets.each { |target| target.purge! }
39
+ targets.each { |target| target.purge!(name) }
40
40
  end
41
41
 
42
42
  end
@@ -23,10 +23,10 @@ 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 --verbose --exclude-from #{exclude_list} #{source_dir}"
26
+ commandline = "tar --create --file #{archive_name} --preserve-permissions --gzip --exclude-from #{exclude_list} #{source_dir}"
27
27
  Outback.debug "executing command: #{commandline}"
28
28
  result = `#{commandline}`
29
- Outback.debug result
29
+ #Outback.debug result
30
30
  [TempArchive.new(archive_name, self)]
31
31
  end
32
32
  end
@@ -14,6 +14,7 @@ module Outback
14
14
  def put(archives)
15
15
  Dir.mkdir(path) unless path.directory?
16
16
  FileUtils.chmod directory_permissions || 0700, path
17
+ size = 0
17
18
  archives.each do |archive|
18
19
  basename = Pathname.new(archive.filename).basename
19
20
  if move
@@ -29,12 +30,14 @@ module Outback
29
30
  if user && group
30
31
  Outback.debug "setting owner #{user}, group #{group} for #{archived_file}"
31
32
  FileUtils.chown user, group, archived_file
32
- end
33
+ end
34
+ size += archived_file.size
33
35
  end
36
+ Outback.debug "#{move ? 'Moved' : 'Copied'} #{archives.size} archives (#{size} bytes) to directory #{path}"
34
37
  end
35
38
 
36
- def list_archives
37
- path.files(Archive::NAME_PATTERN).map { |f| DirectoryArchive.new(f, self) }
39
+ def list_archives(name)
40
+ path.files(Archive::NAME_PATTERN).map { |f| DirectoryArchive.new(f, self) }.select(&its.backup_name == name)
38
41
  end
39
42
 
40
43
  end
@@ -20,12 +20,13 @@ module Outback
20
20
  object_exists = AWS::S3::S3Object.exists?(object_name, bucket)
21
21
  Outback.debug "Checking if object exists: #{object_exists}"
22
22
  end
23
+ Outback.debug "Uploaded #{archives.sum(&:size)} bytes to S3"
23
24
  end
24
25
 
25
- def list_archives
26
+ def list_archives(name)
26
27
  connect
27
28
  entries = AWS::S3::Bucket.objects(bucket).select { |e| e.key.start_with?(prefix.to_s) && e.key[prefix.to_s.size..-1].match(Archive::NAME_PATTERN) }
28
- entries.map { |e| S3Archive.new(e.key, self) }
29
+ entries.map { |e| S3Archive.new(e.key, self) }.select(&its.backup_name == name)
29
30
  end
30
31
  end
31
32
 
@@ -2,12 +2,12 @@ module Outback
2
2
  class Target
3
3
  include Configurable
4
4
 
5
- def outdated_archives
6
- list_archives.select(&:outdated?)
5
+ def outdated_archives(name)
6
+ list_archives(name).select(&:outdated?)
7
7
  end
8
8
 
9
- def purge!
10
- outdated_archives.each &:purge!
9
+ def purge!(name)
10
+ outdated_archives(name).each &:purge!
11
11
  end
12
12
 
13
13
  end
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthias Grosser
@@ -85,6 +85,7 @@ files:
85
85
  - bin/outback
86
86
  - MIT-LICENSE
87
87
  - VERSION
88
+ - README
88
89
  has_rdoc: true
89
90
  homepage: http://rubygems.org/gems/outback
90
91
  licenses: []