shinobi 0.1.0
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/Rakefile +27 -0
- data/VERSION.yml +4 -0
- data/bin/shinobi +4 -0
- data/lib/shinobi.rb +58 -0
- metadata +58 -0
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/lib/shinobi'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "shinobi"
|
10
|
+
gem.executables = "shinobi"
|
11
|
+
gem.summary = "Backup Ninja"
|
12
|
+
gem.email = "steve@curve21.com"
|
13
|
+
gem.homepage = ""
|
14
|
+
gem.description = "Backup Ninja"
|
15
|
+
gem.authors = ["Stephen Bartholomew"]
|
16
|
+
|
17
|
+
gem.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gemgem.github.com"
|
21
|
+
end
|
22
|
+
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
# spec.spec_opts = ['--options', 'spec/spec.opts']
|
27
|
+
end
|
data/VERSION.yml
ADDED
data/bin/shinobi
ADDED
data/lib/shinobi.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
class Shinobi
|
4
|
+
def initialize(config)
|
5
|
+
@config = config
|
6
|
+
@files = []
|
7
|
+
@name = ""
|
8
|
+
end
|
9
|
+
|
10
|
+
def name(name)
|
11
|
+
@name = name
|
12
|
+
end
|
13
|
+
|
14
|
+
def files(*files)
|
15
|
+
@files.concat(files)
|
16
|
+
end
|
17
|
+
|
18
|
+
def databases(*databases)
|
19
|
+
if databases.first == :all
|
20
|
+
@mysql_dump_args = "--all-databases"
|
21
|
+
else
|
22
|
+
@mysql_dump_args = databases.join(" ")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
eval File.read(@config)
|
28
|
+
|
29
|
+
backup_timestamp = Time.now.strftime("%Y%m%d%H%M%s")
|
30
|
+
|
31
|
+
if @mysql_dump_args
|
32
|
+
db_backup_file = "#{@name}-db-backup-#{backup_timestamp}.sql"
|
33
|
+
system "mysqldump -u root #{@mysql_dump_args} > #{db_backup_file}"
|
34
|
+
|
35
|
+
@files << db_backup_file
|
36
|
+
end
|
37
|
+
|
38
|
+
if @files.size > 0
|
39
|
+
full_path_list = []
|
40
|
+
|
41
|
+
@files.each do |path|
|
42
|
+
path = File.expand_path(path)
|
43
|
+
|
44
|
+
Dir[path].each do |full_path|
|
45
|
+
full_path.gsub!(/\s+/, "\\ ")
|
46
|
+
full_path_list << full_path
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
tar_command = "tar -zcf #{@name}-backup-#{backup_timestamp}.tar.gz #{full_path_list.join(' ')}"
|
51
|
+
system tar_command
|
52
|
+
|
53
|
+
if @mysql_dump_args
|
54
|
+
FileUtils.rm(db_backup_file)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shinobi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephen Bartholomew
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-03-20 00:00:00 +00:00
|
13
|
+
default_executable: shinobi
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Backup Ninja
|
17
|
+
email: steve@curve21.com
|
18
|
+
executables:
|
19
|
+
- shinobi
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- Rakefile
|
26
|
+
- VERSION.yml
|
27
|
+
- bin/shinobi
|
28
|
+
- lib/shinobi.rb
|
29
|
+
has_rdoc: true
|
30
|
+
homepage: ""
|
31
|
+
licenses: []
|
32
|
+
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options:
|
35
|
+
- --charset=UTF-8
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
version:
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
requirements: []
|
51
|
+
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.3.5
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Backup Ninja
|
57
|
+
test_files: []
|
58
|
+
|