dropup 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/bin/dropup +110 -0
- data/dropup.gemspec +30 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5a5f5c04597a8168388e2c1088da707fef35bc9d
|
4
|
+
data.tar.gz: b1c8d1f5b67e8f351c311f3a64fbbf2c49e22a66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d4eb6a194d40337505cc71a041070b22e7efe79e46eadb6ce65a593cb3ede06f374efeca01930f71f8721b0fd56c3048ca5e8b3a9aa9ede92cd1a7dc2963778
|
7
|
+
data.tar.gz: 45c00dfb1425e0f25f773561d9ee57026f96f1049d7b935f27277cf9eb2aea8326a92fb59877c36f1a72277e8ac4d71965e1a97753ea21314f5734d1bbf03b75
|
data/Gemfile
ADDED
data/bin/dropup
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler/setup'
|
6
|
+
|
7
|
+
require 'time'
|
8
|
+
require 'optparse'
|
9
|
+
require 'open3'
|
10
|
+
require 'terminal-notifier'
|
11
|
+
|
12
|
+
options = {
|
13
|
+
:size => 400, # in MB
|
14
|
+
:keep => 0, # number of backups to keep
|
15
|
+
:dry => false,
|
16
|
+
:verbose => false,
|
17
|
+
:notification => false
|
18
|
+
}
|
19
|
+
|
20
|
+
opt_parser = OptionParser.new do |opt|
|
21
|
+
opt.banner = "Usage: dropup <dir1> <dir2> <dirN> <destination-%.dmg>"
|
22
|
+
opt.separator ""
|
23
|
+
opt.separator ""
|
24
|
+
opt.separator "Options"
|
25
|
+
|
26
|
+
opt.on("-h", "--help", "help") do
|
27
|
+
puts opt_parser
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
opt.on("-v", "--verbose", "verbose") do
|
32
|
+
options[:verbose] = true
|
33
|
+
end
|
34
|
+
|
35
|
+
opt.on("-n", "--notification", "notification") do
|
36
|
+
options[:notification] = true
|
37
|
+
end
|
38
|
+
|
39
|
+
opt.on("-k", "--keep KEEP", "keep") do |keep|
|
40
|
+
options[:keep] = keep.to_i - 1
|
41
|
+
end
|
42
|
+
|
43
|
+
opt.on("-s", "--size SIZE", "size") do |size|
|
44
|
+
options[:size] = size.to_i
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
opt_parser.parse!
|
49
|
+
|
50
|
+
if ARGV.length < 2
|
51
|
+
puts opt_parser
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
55
|
+
destination = File.expand_path(ARGV.pop)
|
56
|
+
|
57
|
+
backups = Dir[destination.gsub(/%/,'*')].sort.reverse
|
58
|
+
|
59
|
+
puts "Backups: #{backups}" if options[:verbose]
|
60
|
+
|
61
|
+
while backups.length > options[:keep]
|
62
|
+
backup = backups.pop
|
63
|
+
puts "Deleting: #{backup}" if options[:verbose]
|
64
|
+
File.delete(backup)
|
65
|
+
end
|
66
|
+
|
67
|
+
backup = destination.gsub(/%/, Time.now.strftime("%Y%m%d%M%H%S%L"))
|
68
|
+
|
69
|
+
puts "Creating: #{backup}" if options[:verbose]
|
70
|
+
|
71
|
+
password = %x[security find-internet-password -s dropup -a password -g 2>&1][/^password:\s"([^"]*)"/,1]
|
72
|
+
|
73
|
+
if password == ''
|
74
|
+
puts "Set a password: security add-internet-password -s dropup -U -T \"\" -a password -w <PASSWORD>"
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
cmd = %W(
|
79
|
+
hdiutil create
|
80
|
+
-encryption AES-256
|
81
|
+
-stdinpass
|
82
|
+
-volname "Backup"
|
83
|
+
-format UDZO
|
84
|
+
-megabytes #{options[:size]}
|
85
|
+
#{ARGV.map{|s| "-srcfolder \"#{File.expand_path(s)}\"" }.join(' ')}
|
86
|
+
"#{File.expand_path(backup)}"
|
87
|
+
).join(' ')
|
88
|
+
|
89
|
+
puts "Command: #{cmd}" if options[:verbose]
|
90
|
+
|
91
|
+
if not options[:dry]
|
92
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait|
|
93
|
+
stdin.printf(password)
|
94
|
+
stdin.close
|
95
|
+
|
96
|
+
TerminalNotifier.notify('Backup Starting') if options[:notification]
|
97
|
+
puts "Building dmg" if options[:verbose]
|
98
|
+
|
99
|
+
if wait.value == 0 then
|
100
|
+
|
101
|
+
TerminalNotifier.notify('Backup Successful', :title => 'Success') if options[:notification]
|
102
|
+
puts "Success" if options[:verbose]
|
103
|
+
|
104
|
+
else
|
105
|
+
|
106
|
+
TerminalNotifier.notify('Backup Failed', :title => 'Error', :sound => 'default') if options[:notification]
|
107
|
+
puts "Error: #{stderr.read}" if options[:verbose]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/dropup.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
spec = Gem::Specification.new do |s|
|
2
|
+
s.name = 'dropup'
|
3
|
+
s.version = '0.2'
|
4
|
+
s.date = '2014-10-01'
|
5
|
+
|
6
|
+
s.authors = [ 'Torsten Curdt' ]
|
7
|
+
s.email = [ 'tcurdt@vafer.org' ]
|
8
|
+
s.homepage = 'http://github.com/tcurdt/dropup'
|
9
|
+
s.summary = 'dropup tool'
|
10
|
+
s.description = 'dropup tool long'
|
11
|
+
|
12
|
+
s.rubyforge_project = s.name
|
13
|
+
|
14
|
+
s.license = 'Apache'
|
15
|
+
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
|
18
|
+
s.has_rdoc = false
|
19
|
+
|
20
|
+
s.files = Dir["{lib,man,spec}/*"] + Dir["{README,LICENSE}*"] + Dir["*{.gemspec,file}"]
|
21
|
+
s.test_files = s.files.select { |path| path =~ /^spec\/.*_spec\.rb/ }
|
22
|
+
s.executables = Dir["bin/*"].map {|f| File.basename f }
|
23
|
+
s.require_paths = ['lib']
|
24
|
+
|
25
|
+
s.requirements = <<-EOS
|
26
|
+
Nothing?
|
27
|
+
EOS
|
28
|
+
|
29
|
+
s.add_dependency 'terminal-notifier', '~> 1.6'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dropup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Torsten Curdt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: terminal-notifier
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
description: dropup tool long
|
28
|
+
email:
|
29
|
+
- tcurdt@vafer.org
|
30
|
+
executables:
|
31
|
+
- dropup
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- Gemfile
|
36
|
+
- bin/dropup
|
37
|
+
- dropup.gemspec
|
38
|
+
homepage: http://github.com/tcurdt/dropup
|
39
|
+
licenses:
|
40
|
+
- Apache
|
41
|
+
metadata: {}
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements:
|
57
|
+
- |
|
58
|
+
Nothing?
|
59
|
+
rubyforge_project: dropup
|
60
|
+
rubygems_version: 2.4.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: dropup tool
|
64
|
+
test_files: []
|