backup_demon 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/lib/backup_demon/cli.rb +6 -0
- data/lib/backup_demon/daemon.rb +17 -1
- data/lib/backup_demon/notifier.rb +22 -0
- data/lib/backup_demon/version.rb +1 -1
- metadata +4 -3
data/Gemfile.lock
CHANGED
data/lib/backup_demon/cli.rb
CHANGED
data/lib/backup_demon/daemon.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
module BackupDemon
|
2
4
|
class Daemon
|
3
5
|
def initialize(directories, device_path, mount_point = "/mnt/backuphdd")
|
@@ -12,12 +14,26 @@ module BackupDemon
|
|
12
14
|
|
13
15
|
if @drive.exists? && @drive.different?
|
14
16
|
procline 'Found Drive'
|
17
|
+
|
18
|
+
Notifier.alert("Starting Backup") do
|
19
|
+
"Starting Backup on #{Date.today}"
|
20
|
+
end
|
21
|
+
|
15
22
|
if @drive.mount(@mount_point)
|
16
23
|
@directories.each do |source|
|
17
24
|
procline "Backing up #{source}"
|
18
25
|
Sync.start(source, @drive.mount_point)
|
19
26
|
end
|
20
|
-
|
27
|
+
@drive.ummount
|
28
|
+
|
29
|
+
Notifier.alert("Backup Complete") do
|
30
|
+
"Backup Complete on #{Date.today}"
|
31
|
+
end
|
32
|
+
else
|
33
|
+
Notifier.alert("Backup Error") do
|
34
|
+
"Unable to mount the backup disk."
|
35
|
+
end
|
36
|
+
end
|
21
37
|
end
|
22
38
|
|
23
39
|
Kernel.sleep(interval)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module BackupDemon
|
2
|
+
class Notifier
|
3
|
+
def initialize(recepients)
|
4
|
+
@recepients = [recepients].flatten
|
5
|
+
end
|
6
|
+
|
7
|
+
def mail(subject, &block)
|
8
|
+
if block_given?
|
9
|
+
msg = yield
|
10
|
+
|
11
|
+
@recepients.each do |recepient|
|
12
|
+
`echo #{msg} | mail -s "#{subject}" #{recepient}`
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.alert(subject, &block)
|
18
|
+
notifier = new(BackupDemon.config.recepients)
|
19
|
+
notifier.mail(subject, block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/backup_demon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backup_demon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/backup_demon/core_ext/hash.rb
|
50
50
|
- lib/backup_demon/daemon.rb
|
51
51
|
- lib/backup_demon/device.rb
|
52
|
+
- lib/backup_demon/notifier.rb
|
52
53
|
- lib/backup_demon/sync.rb
|
53
54
|
- lib/backup_demon/version.rb
|
54
55
|
homepage: https://github.com/ryanfaerman/backup_demon
|
@@ -65,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
66
|
version: '0'
|
66
67
|
segments:
|
67
68
|
- 0
|
68
|
-
hash: -
|
69
|
+
hash: -989672854755456934
|
69
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
71
|
none: false
|
71
72
|
requirements:
|
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
75
|
version: '0'
|
75
76
|
segments:
|
76
77
|
- 0
|
77
|
-
hash: -
|
78
|
+
hash: -989672854755456934
|
78
79
|
requirements: []
|
79
80
|
rubyforge_project:
|
80
81
|
rubygems_version: 1.8.24
|