oldtime 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +14 -20
- data/README.md +76 -22
- data/lib/oldtime/cli.rb +7 -7
- data/lib/oldtime/rc.rb +7 -7
- data/lib/oldtime/version.rb +1 -1
- data/lib/oldtime.rb +2 -2
- data/oldtime.gemspec +7 -5
- data/spec/oldtime_spec.rb +14 -0
- metadata +39 -5
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
3
|
gem "thor"
|
4
|
-
gem "
|
5
|
-
gem "pa",
|
6
|
-
gem "
|
4
|
+
gem "tagen", "~>1.1.4"
|
5
|
+
gem "pa", "~>1.2.0"
|
6
|
+
gem "optimism", "~>3.1.0"
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "rspec"
|
10
10
|
gem "watchr"
|
11
|
-
|
11
|
+
gem "rag"
|
12
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,3 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /home/guten/dev/one/optimism
|
3
|
-
specs:
|
4
|
-
optimism (3.0.4)
|
5
|
-
hike (~> 1.2.0)
|
6
|
-
|
7
|
-
PATH
|
8
|
-
remote: /home/guten/dev/one/pa
|
9
|
-
specs:
|
10
|
-
pa (1.1.4)
|
11
|
-
|
12
|
-
PATH
|
13
|
-
remote: /home/guten/dev/one/tagen
|
14
|
-
specs:
|
15
|
-
tagen (1.1.2)
|
16
|
-
activesupport (~> 3.1.0)
|
17
|
-
|
18
1
|
GEM
|
19
2
|
remote: http://rubygems.org/
|
20
3
|
specs:
|
@@ -23,6 +6,14 @@ GEM
|
|
23
6
|
diff-lcs (1.1.3)
|
24
7
|
hike (1.2.1)
|
25
8
|
multi_json (1.0.4)
|
9
|
+
optimism (3.1.0)
|
10
|
+
hike (~> 1.2.0)
|
11
|
+
pa (1.2.1)
|
12
|
+
rag (1.2.0)
|
13
|
+
optimism (~> 3.1.0)
|
14
|
+
pa (~> 1.2.0)
|
15
|
+
tagen (~> 1.1.0)
|
16
|
+
thor (~> 0.14.0)
|
26
17
|
rspec (2.8.0)
|
27
18
|
rspec-core (~> 2.8.0)
|
28
19
|
rspec-expectations (~> 2.8.0)
|
@@ -31,6 +22,8 @@ GEM
|
|
31
22
|
rspec-expectations (2.8.0)
|
32
23
|
diff-lcs (~> 1.1.2)
|
33
24
|
rspec-mocks (2.8.0)
|
25
|
+
tagen (1.1.4)
|
26
|
+
activesupport (~> 3.1.0)
|
34
27
|
thor (0.14.6)
|
35
28
|
watchr (0.7)
|
36
29
|
|
@@ -38,9 +31,10 @@ PLATFORMS
|
|
38
31
|
ruby
|
39
32
|
|
40
33
|
DEPENDENCIES
|
41
|
-
optimism
|
42
|
-
pa
|
34
|
+
optimism (~> 3.1.0)
|
35
|
+
pa (~> 1.2.0)
|
36
|
+
rag
|
43
37
|
rspec
|
44
|
-
tagen
|
38
|
+
tagen (~> 1.1.4)
|
45
39
|
thor
|
46
40
|
watchr
|
data/README.md
CHANGED
@@ -1,39 +1,92 @@
|
|
1
|
-
Oldtime, a highly
|
1
|
+
Oldtime, a highly customizable and configurable backup & restore system
|
2
2
|
=================================================================
|
3
3
|
|
4
4
|
| Homepage: | https://github.com/GutenYe/oldtime |
|
5
|
-
|
6
|
-
| Author: | Guten
|
7
|
-
| License: | MIT-LICENSE
|
8
|
-
| Documentation: | http://rubydoc.info/gems/oldtime/frames
|
5
|
+
|----------------|-------------------------------------------|
|
6
|
+
| Author: | Guten |
|
7
|
+
| License: | MIT-LICENSE |
|
8
|
+
| Documentation: | http://rubydoc.info/gems/oldtime/frames |
|
9
9
|
| Issue Tracker: | https://github.com/GutenYe/oldtime/issues |
|
10
10
|
|
11
|
-
Overview
|
12
|
-
--------
|
13
11
|
|
14
|
-
|
12
|
+
Getting Started
|
13
|
+
--------------
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
For example, we want to backup /oldtime to /tmp/hello.oldtime using rsync.
|
16
|
+
|
17
|
+
create hello example from https://github.com/GutenYe/oldtime-hello-example
|
18
|
+
|
19
|
+
$ git clone git://github.com/GutenYe/oldtime-hello-example.git /tmp/oldtime
|
20
|
+
$ sudo ln -s /tmp/oldtime /oldtime
|
21
|
+
|
22
|
+
it will have these files:
|
23
|
+
|
24
|
+
/oldtime/oldtime/
|
25
|
+
hello.conf
|
26
|
+
hello/
|
27
|
+
backup.hello
|
28
|
+
|
29
|
+
# /oldtime/oldtimerc # an Optimsim config file.
|
30
|
+
media = "/tmp" # get this variable by Rc.media.
|
31
|
+
|
32
|
+
# /oldtime/oldtime/hello/backup.hello
|
33
|
+
|
34
|
+
/oldtime/ <%=Rc.media%>/hello.oldtime/ # an ERB template.
|
35
|
+
|
36
|
+
[exclude]
|
37
|
+
/.git
|
38
|
+
/oldtimerc
|
39
|
+
|
40
|
+
# /oldtime/hello.conf
|
41
|
+
|
42
|
+
require "oldtime/rsync"
|
43
|
+
|
44
|
+
configure <<EOF
|
45
|
+
backup:
|
46
|
+
rsync.options = "-av --delete" # get this variable by Rc.backup.rsync.options
|
47
|
+
|
48
|
+
restore:
|
49
|
+
rsync.options = "-av"
|
50
|
+
EOF
|
51
|
+
|
52
|
+
backup do
|
53
|
+
rsync2 "backup.hello" # run rsync command read from /oldtime/hello/backup.hello file
|
54
|
+
end
|
55
|
+
|
56
|
+
restore do
|
57
|
+
rsync "<%=Rc.media%>/hello.oldtime/ /oldtime/" # run rsync command
|
58
|
+
end
|
59
|
+
|
60
|
+
Let's begin.
|
61
|
+
|
62
|
+
$ oldtime backup hello
|
63
|
+
# it calls "rsync -av --delete --exclude-from /tmp/hello.xx/exclude /oldtime/ /tmp/hello.oldtime/"
|
64
|
+
|
65
|
+
$ oldtime restore hello
|
66
|
+
# it calls "rsync -av /tmp/hello.oldtime/ /oldtime/"
|
18
67
|
|
19
|
-
|
68
|
+
for a real world example, see [oldtime-archlinux-solution](https://github.com/GutenYe/oldtime-archlinux-solution).
|
20
69
|
|
21
|
-
|
22
|
-
-----
|
70
|
+
see Optimism Syntax: https://github.com/GutenYe/optimism
|
23
71
|
|
24
|
-
|
72
|
+
see ERB Syntax: http://ruby-doc.org/stdlib-1.9.3/libdoc/erb/rdoc/ERB.html
|
25
73
|
|
26
74
|
Install
|
27
|
-
|
75
|
+
-------
|
28
76
|
|
29
|
-
|
77
|
+
# Archlinux
|
78
|
+
pacman -S ruby rsync
|
79
|
+
gem install oldtime
|
30
80
|
|
31
|
-
|
32
|
-
|
81
|
+
Note on Patches/Pull Requests
|
82
|
+
-----------------------------
|
33
83
|
|
34
|
-
|
35
|
-
|
36
|
-
|
84
|
+
1. Fork the project.
|
85
|
+
2. Make your feature addition or bug fix.
|
86
|
+
3. Add tests for it. This is important so I don't break it in a future version unintentionally.
|
87
|
+
4. Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
88
|
+
5. Send me a pull request. Bonus points for topic branches.
|
89
|
+
6. Coding Style Guide: https://gist.github.com/1105334
|
37
90
|
|
38
91
|
Credits
|
39
92
|
--------
|
@@ -43,7 +96,8 @@ Credits
|
|
43
96
|
Resources
|
44
97
|
---------
|
45
98
|
|
46
|
-
|
99
|
+
* [Ruby](http://www.ruby-lang.org/en): A Programmer's Best Friend
|
100
|
+
* [Archlinux](http://www.archlinux.org): A simple, lightweight distribution
|
47
101
|
|
48
102
|
Copyright
|
49
103
|
---------
|
data/lib/oldtime/cli.rb
CHANGED
@@ -7,19 +7,19 @@ module Oldtime
|
|
7
7
|
# default_task :install
|
8
8
|
class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
|
9
9
|
class_option "verbose", :aliases => "-V", :type => :boolean, :banner => "Enable verbose output mode"
|
10
|
-
class_option "
|
11
|
-
class_option "user-mode", :aliases => "-u", :type => :boolean, :banner => "Enter into User mode"
|
10
|
+
class_option "dir", :aliases => "-d", :type => :string, :banner => "config directory"
|
12
11
|
|
13
12
|
def initialize(*)
|
14
13
|
super
|
15
|
-
|
14
|
+
o = options.dup
|
15
|
+
the_shell = (o["no-color"] ? Thor::Shell::Basic.new : shell)
|
16
16
|
Oldtime.ui = UI::Shell.new(the_shell)
|
17
|
-
Oldtime.ui.debug! if
|
17
|
+
Oldtime.ui.debug! if o["verbose"]
|
18
18
|
|
19
|
-
|
20
|
-
Rc
|
19
|
+
home = Rc.p.home = o["dir"] || Rc.p.home
|
20
|
+
homerc = Rc.p.homerc = Pa("#{home}rc")
|
21
21
|
|
22
|
-
Rc
|
22
|
+
Rc << Optimism.require(homerc.absolute2)
|
23
23
|
end
|
24
24
|
|
25
25
|
desc "backup <profile> [instance]", "begin backup process."
|
data/lib/oldtime/rc.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# user config
|
2
|
-
p:
|
3
|
-
home = nil
|
4
|
-
oldtime = Pa("/oldtime")
|
5
|
-
|
6
2
|
backup:
|
7
3
|
rsync.options = ""
|
8
4
|
|
5
|
+
restore:
|
6
|
+
rsync.options = ""
|
7
|
+
|
9
8
|
# system config
|
10
9
|
|
10
|
+
p:
|
11
|
+
home = Pa("/oldtime/oldtime")
|
12
|
+
homerc = nil
|
13
|
+
|
11
14
|
backup_blks = {}
|
12
15
|
restore_blks = {}
|
13
|
-
|
14
|
-
restore:
|
15
|
-
rsync.options = ""
|
data/lib/oldtime/version.rb
CHANGED
data/lib/oldtime.rb
CHANGED
@@ -41,13 +41,13 @@ private
|
|
41
41
|
|
42
42
|
def check_mountpoint(path)
|
43
43
|
unless Pa.mountpoint?(path)
|
44
|
-
raise Error, "`#{path}' is unmounted."
|
44
|
+
raise Oldtime::Error, "`#{path}' is unmounted."
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def check_root
|
49
49
|
unless Process.uid == 0
|
50
|
-
raise Error, "need root privilege to run this script."
|
50
|
+
raise Oldtime::Error, "need root privilege to run this script."
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/oldtime.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
$: <<
|
2
|
-
require "
|
1
|
+
$: << File.expand_path("../lib", __FILE__)
|
2
|
+
require "oldtime/version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "oldtime"
|
6
6
|
s.version = Oldtime::VERSION
|
7
|
-
s.summary = "
|
7
|
+
s.summary = "a highly customizable and configurable backup & restore system"
|
8
8
|
s.description = <<-EOF
|
9
|
-
|
9
|
+
The backup & restore system that fits you well. It's a highly customizable and configurable backup & restore system.
|
10
10
|
EOF
|
11
11
|
|
12
12
|
s.author = "Guten"
|
@@ -17,5 +17,7 @@ the backup & restore sytem
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
#s.executables = ["x"]
|
19
19
|
|
20
|
-
|
20
|
+
s.add_dependency "tagen", "~>1.1.4"
|
21
|
+
s.add_dependency "pa", "~>1.2.0"
|
22
|
+
s.add_dependency "optimism", "~>3.1.0"
|
21
23
|
end
|
data/spec/oldtime_spec.rb
CHANGED
@@ -20,4 +20,18 @@ describe Kernel do
|
|
20
20
|
|
21
21
|
Rc.restore_blks[:foo].call.should == "restore"
|
22
22
|
end
|
23
|
+
|
24
|
+
describe "#check_root" do
|
25
|
+
it "works" do
|
26
|
+
Process.stub(:uid){ 1000 }
|
27
|
+
lambda { check_root }.should raise_error(Oldtime::Error)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#check_mountpoint" do
|
32
|
+
it "works" do
|
33
|
+
Pa.stub(:mountpoint?){ false }
|
34
|
+
lambda { check_mountpoint("x") }.should raise_error(Oldtime::Error)
|
35
|
+
end
|
36
|
+
end
|
23
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oldtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,43 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
-
dependencies:
|
14
|
-
|
12
|
+
date: 2012-02-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: tagen
|
16
|
+
requirement: &7492700 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.4
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *7492700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: pa
|
27
|
+
requirement: &7452220 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *7452220
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: optimism
|
38
|
+
requirement: &7416380 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.1.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *7416380
|
47
|
+
description: ! 'The backup & restore system that fits you well. It''s a highly customizable
|
48
|
+
and configurable backup & restore system.
|
15
49
|
|
16
50
|
'
|
17
51
|
email: ywzhaifei@gmail.com
|
@@ -63,6 +97,6 @@ rubyforge_project: xx
|
|
63
97
|
rubygems_version: 1.8.11
|
64
98
|
signing_key:
|
65
99
|
specification_version: 3
|
66
|
-
summary:
|
100
|
+
summary: a highly customizable and configurable backup & restore system
|
67
101
|
test_files: []
|
68
102
|
has_rdoc:
|