dropup 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dropup +48 -35
- data/dropup.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a03754a4747eef5b1938fe47b553685ab63be063
|
4
|
+
data.tar.gz: 92bedd3c2711fe348e1a1c4911811bcbabb0c0b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1480e362f5fc041135570edde3b870b0f8601edd732efdf2adc20883b940e8dd28b0ec9b4c935a8311aee1449dc7dec7b2c6a3f6214ee3af5d357052dba66200
|
7
|
+
data.tar.gz: 4043a53236c625b587d0004664e397127a548e4f80eff2030e0d8f85a253a6ccd9f906c62ecc5e6a547a5be050f35e999991647e3b51323cca1458d5b352338f
|
data/bin/dropup
CHANGED
@@ -8,12 +8,14 @@ require 'time'
|
|
8
8
|
require 'optparse'
|
9
9
|
require 'open3'
|
10
10
|
require 'terminal-notifier'
|
11
|
+
require 'fileutils'
|
11
12
|
|
12
13
|
options = {
|
13
14
|
:size => 400, # in MB
|
14
15
|
:keep => 0, # number of backups to keep
|
15
16
|
:verbose => false,
|
16
|
-
:notification => false
|
17
|
+
:notification => false,
|
18
|
+
:temp => '/tmp/backup-%.dmg'
|
17
19
|
}
|
18
20
|
|
19
21
|
opt_parser = OptionParser.new do |opt|
|
@@ -42,6 +44,10 @@ opt_parser = OptionParser.new do |opt|
|
|
42
44
|
opt.on("-s", "--size SIZE", "size") do |size|
|
43
45
|
options[:size] = size.to_i
|
44
46
|
end
|
47
|
+
|
48
|
+
opt.on("-t", "--temp TEMP", "temp") do |temp|
|
49
|
+
options[:temp] = temp.to_s
|
50
|
+
end
|
45
51
|
end
|
46
52
|
|
47
53
|
opt_parser.parse!
|
@@ -51,59 +57,66 @@ if ARGV.length < 2
|
|
51
57
|
exit
|
52
58
|
end
|
53
59
|
|
54
|
-
|
60
|
+
def backup(srcs, temp, password, size)
|
55
61
|
|
56
|
-
|
62
|
+
cmd = %W(
|
63
|
+
hdiutil create
|
64
|
+
-encryption AES-256
|
65
|
+
-stdinpass
|
66
|
+
-volname "Backup"
|
67
|
+
-format UDZO
|
68
|
+
-megabytes #{size}
|
69
|
+
#{srcs.map{|s| "-srcfolder \"#{File.expand_path(s)}\"" }.join(' ')}
|
70
|
+
"#{File.expand_path(temp)}"
|
71
|
+
).join(' ')
|
72
|
+
|
73
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait|
|
74
|
+
stdin.printf(password)
|
75
|
+
stdin.close
|
57
76
|
|
58
|
-
|
77
|
+
yield wait.value == 0
|
59
78
|
|
60
|
-
|
61
|
-
backup = backups.pop
|
62
|
-
puts "Deleting: #{backup}" if options[:verbose]
|
63
|
-
File.delete(backup)
|
79
|
+
end
|
64
80
|
end
|
65
81
|
|
66
|
-
|
67
|
-
|
68
|
-
|
82
|
+
time = Time.now.strftime("%Y%m%d%M%H%S%L")
|
83
|
+
temp_pattern = File.expand_path(options[:temp])
|
84
|
+
dest_pattern = File.expand_path(ARGV.pop)
|
69
85
|
|
70
86
|
password = %x[security find-internet-password -s dropup -a password -g 2>&1][/^password:\s"([^"]*)"/,1]
|
71
|
-
|
72
87
|
if password.nil? || password.length == 0
|
73
88
|
puts "Set a password: security add-internet-password -s dropup -U -T \"\" -a password -w <PASSWORD>"
|
74
89
|
exit
|
75
90
|
end
|
76
91
|
|
77
|
-
|
78
|
-
|
79
|
-
-encryption AES-256
|
80
|
-
-stdinpass
|
81
|
-
-volname "Backup"
|
82
|
-
-format UDZO
|
83
|
-
-megabytes #{options[:size]}
|
84
|
-
#{ARGV.map{|s| "-srcfolder \"#{File.expand_path(s)}\"" }.join(' ')}
|
85
|
-
"#{File.expand_path(backup)}"
|
86
|
-
).join(' ')
|
92
|
+
temp = temp_pattern.gsub(/%/, time)
|
93
|
+
dest = dest_pattern.gsub(/%/, time)
|
87
94
|
|
88
|
-
puts "
|
95
|
+
puts "Creating: #{dest}" if options[:verbose]
|
89
96
|
|
90
|
-
|
91
|
-
Open3.popen3(cmd) do |stdin, stdout, stderr, wait|
|
92
|
-
stdin.printf(password)
|
93
|
-
stdin.close
|
97
|
+
backup(ARGV, temp, password, options[:size]) do |success|
|
94
98
|
|
95
|
-
|
96
|
-
|
99
|
+
TerminalNotifier.notify('Backup Starting') if options[:notification]
|
100
|
+
puts "Building dmg" if options[:verbose]
|
97
101
|
|
98
|
-
|
102
|
+
if success then
|
99
103
|
|
100
|
-
|
101
|
-
|
104
|
+
TerminalNotifier.notify('Backup Successful', :title => 'Success') if options[:notification]
|
105
|
+
puts "Success" if options[:verbose]
|
102
106
|
|
103
|
-
|
107
|
+
backups = Dir[dest_pattern.gsub(/%/,'*')].sort.reverse
|
104
108
|
|
105
|
-
|
106
|
-
|
109
|
+
while backups.length > options[:keep]
|
110
|
+
backup = backups.pop
|
111
|
+
puts "Deleting: #{backup}" if options[:verbose]
|
112
|
+
File.delete(backup)
|
107
113
|
end
|
114
|
+
|
115
|
+
FileUtils.move(temp, dest)
|
116
|
+
|
117
|
+
else
|
118
|
+
|
119
|
+
TerminalNotifier.notify('Backup Failed', :title => 'Error', :sound => 'default') if options[:notification]
|
120
|
+
puts "Error: #{stderr.read}" if options[:verbose]
|
108
121
|
end
|
109
122
|
end
|
data/dropup.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Torsten Curdt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: terminal-notifier
|