BackupMan 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +23 -0
- data/.yardopts +1 -0
- data/LICENSE +674 -0
- data/README.rdoc +138 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/backup_man +10 -0
- data/examples/example-host-config +60 -0
- data/lib/backup_man/backup.rb +110 -0
- data/lib/backup_man/backup_man.rb +45 -0
- data/lib/backup_man/cli.rb +101 -0
- data/lib/backup_man/command.rb +74 -0
- data/lib/backup_man/dsl.rb +47 -0
- data/lib/backup_man/log.rb +48 -0
- data/lib/backup_man/mysql.rb +30 -0
- data/lib/backup_man/rsync.rb +24 -0
- data/lib/backup_man/tar.rb +29 -0
- data/lib/backup_man.rb +18 -0
- data/spec/BackupMan_spec.rb +25 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +17 -0
- metadata +107 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'backup_man/backup'
|
2
|
+
require 'backup_man/command'
|
3
|
+
|
4
|
+
module BackupMan
|
5
|
+
class Mysql < Backup
|
6
|
+
|
7
|
+
# we need a name for our backup-file (DSL)
|
8
|
+
def_dsl :filename
|
9
|
+
|
10
|
+
# options for the mysqldump run (DSL)
|
11
|
+
def_dsl :options
|
12
|
+
|
13
|
+
def set_defaults
|
14
|
+
super
|
15
|
+
@filename = "#{Date.today}-mysqlfull.sql.gz"
|
16
|
+
@options = '--all-databases -u root'
|
17
|
+
end
|
18
|
+
|
19
|
+
def _run
|
20
|
+
remote_cmd = "mysqldump #{@options}"
|
21
|
+
Command.new("#{ssh_connect_cmd} '#{remote_cmd} | gzip' > '#{@backup_directory}/#{@filename}'").run
|
22
|
+
end
|
23
|
+
|
24
|
+
# returns true if the backup already exists
|
25
|
+
def exists?
|
26
|
+
File.exists? "#{@backup_directory}/#{@filename}"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'backup_man/backup'
|
2
|
+
require 'backup_man/command'
|
3
|
+
|
4
|
+
module BackupMan
|
5
|
+
class Rsync < Backup
|
6
|
+
|
7
|
+
# options for the rsync run (DSL)
|
8
|
+
def_dsl :options
|
9
|
+
|
10
|
+
def set_defaults
|
11
|
+
@backup_directory = "#{BackupMan.instance.destdir}/#{@name}/rsync" unless @backup_directory
|
12
|
+
super
|
13
|
+
@options = "-azR --delete"
|
14
|
+
end
|
15
|
+
|
16
|
+
def _run
|
17
|
+
@data_sources.each do |dir|
|
18
|
+
Command.new("rsync #{@options} -e '#{BackupMan.instance.ssh_app}' '#{@user}@#{@host}:#{dir}' '#{@backup_directory}'").run
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'backup_man/backup'
|
2
|
+
require 'backup_man/command'
|
3
|
+
require 'backup_man/dsl'
|
4
|
+
|
5
|
+
module BackupMan
|
6
|
+
class Tar < Backup
|
7
|
+
|
8
|
+
def_dsl :filename
|
9
|
+
def_dsl :options
|
10
|
+
|
11
|
+
def set_defaults
|
12
|
+
super
|
13
|
+
@filename = "#{Date.today}-files.tgz"
|
14
|
+
@options = "zP"
|
15
|
+
end
|
16
|
+
|
17
|
+
def _run
|
18
|
+
remote_cmd = "tar -c#{@options}f - ", @data_sources.join(" ")
|
19
|
+
Command.new("#{ssh_connect_cmd} #{remote_cmd} > '#{@backup_directory}/#{@filename}'").run
|
20
|
+
end
|
21
|
+
|
22
|
+
# returns true if the backup already exists
|
23
|
+
def exists?
|
24
|
+
File.exists? "#{@backup_directory}/#{@filename}"
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/lib/backup_man.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
def require_relative(relative_feature)
|
5
|
+
c = caller.first
|
6
|
+
fail "Can't parse #{c}" unless c.rindex(/:\d+(:in `.*')?$/)
|
7
|
+
file = $`
|
8
|
+
if /\A\((.*)\)/ =~ file # eval, etc.
|
9
|
+
raise LoadError, "require_relative is called in #{$1}"
|
10
|
+
end
|
11
|
+
absolute = File.expand_path(relative_feature,
|
12
|
+
File.dirname(file))
|
13
|
+
require absolute
|
14
|
+
end
|
15
|
+
|
16
|
+
module BackupMan
|
17
|
+
TESTING = false
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module BackupMan
|
4
|
+
describe "CLI" do
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
|
8
|
+
it "should exit cleanly and print usage when -h is used" do
|
9
|
+
argv = ["-h"]
|
10
|
+
out = StringIO.new
|
11
|
+
lambda { ::BackupMan::CLI.execute( out, argv ) }.should raise_error SystemExit
|
12
|
+
out.string.should include("Usage: spec [options] {configname | configpath}")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should print an error when the log file is not writeable and continue to run cleanly" do
|
16
|
+
argv = ["-l", "/tmp/does/not/exist.log"]
|
17
|
+
out = StringIO.new
|
18
|
+
$stderr = StringIO.new
|
19
|
+
lambda { ::BackupMan::CLI.execute( out, ARGV) }.should_not raise_error SystemExit
|
20
|
+
$stderr.string.should include("Log file is not writeable")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'backup_man'
|
4
|
+
require 'backup_man/cli'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
|
8
|
+
Spec::Runner.configure do |config|
|
9
|
+
|
10
|
+
config.before do
|
11
|
+
Log = mock("logger") unless defined? Log
|
12
|
+
@log = mock("logger instance")
|
13
|
+
@log.stub(:debug)
|
14
|
+
Log.stub(:instance).and_return(@log)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: BackupMan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Markus Strauss
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-20 00:00:00 +01:00
|
13
|
+
default_executable: backup_man
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yard
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: log4r
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.1.2
|
44
|
+
version:
|
45
|
+
description: A tool for system administrators to easily configure pull-over-SSH backups. Install this gem on your backup server. Configure your backups definitions in /etc/backup_man and run backup_man from cron to securely pull your data over SSH.
|
46
|
+
email: Markus@ITstrauss.eu
|
47
|
+
executables:
|
48
|
+
- backup_man
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- .yardopts
|
58
|
+
- LICENSE
|
59
|
+
- README.rdoc
|
60
|
+
- Rakefile
|
61
|
+
- VERSION
|
62
|
+
- bin/backup_man
|
63
|
+
- examples/example-host-config
|
64
|
+
- lib/backup_man.rb
|
65
|
+
- lib/backup_man/backup.rb
|
66
|
+
- lib/backup_man/backup_man.rb
|
67
|
+
- lib/backup_man/cli.rb
|
68
|
+
- lib/backup_man/command.rb
|
69
|
+
- lib/backup_man/dsl.rb
|
70
|
+
- lib/backup_man/log.rb
|
71
|
+
- lib/backup_man/mysql.rb
|
72
|
+
- lib/backup_man/rsync.rb
|
73
|
+
- lib/backup_man/tar.rb
|
74
|
+
- spec/BackupMan_spec.rb
|
75
|
+
- spec/spec.opts
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
has_rdoc: true
|
78
|
+
homepage: http://github.com/oowoo/BackupMan
|
79
|
+
licenses: []
|
80
|
+
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- --charset=UTF-8
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
version:
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project: backupman
|
101
|
+
rubygems_version: 1.3.5
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: A tool for system administrators to easily configure pull-over-SSH backups.
|
105
|
+
test_files:
|
106
|
+
- spec/BackupMan_spec.rb
|
107
|
+
- spec/spec_helper.rb
|