mite-backup 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/bin/mite-backup +15 -6
- data/lib/mite-backup.rb +8 -3
- data/lib/mite-backup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a117790317b4837a4f8e2cd95226457a36b089494e74a39ae443fa0fc6f03cf3
|
4
|
+
data.tar.gz: 278c4c22b657de5c21bbfab81c059d6d5beae1a9c2e5c15972142511456ff7c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0ed983b6beb773b1e5bf1cf95fee71464c2b26a1248f44078b49fc43b8990b786ced405a5e9bfa884a19a10d78e453b5e1d7d946259738767a510e79d3c585a
|
7
|
+
data.tar.gz: dafd207a7c3c4e29df78c69d74bc76c675bb23dd4c93b456b1bb7ad692ac2f15317d1e391e89fa15e75aa30e825bc19ae07c45a42bc270214400562969ff32e6
|
data/bin/mite-backup
CHANGED
@@ -5,7 +5,9 @@ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
|
5
5
|
require 'mite-backup'
|
6
6
|
require 'optparse'
|
7
7
|
|
8
|
-
@options = {
|
8
|
+
@options = {
|
9
|
+
"wait_for" => MiteBackup::DEFAULT_WAIT_FOR
|
10
|
+
}
|
9
11
|
|
10
12
|
parser = OptionParser.new do |opts|
|
11
13
|
opts.banner = "Usage: mite-backup COMMAND [options]"
|
@@ -13,18 +15,25 @@ parser = OptionParser.new do |opts|
|
|
13
15
|
opts.separator ""
|
14
16
|
opts.separator "Options:"
|
15
17
|
|
16
|
-
opts.on("-a", "--account
|
18
|
+
opts.on("-a", "--account ACCOUNT-SUBDOMAIN", "your mite account subdomain (without .mite.yo.lk)") do |account|
|
17
19
|
@options["account"] = account
|
18
20
|
end
|
19
21
|
|
20
|
-
opts.on("-e", "--email
|
22
|
+
opts.on("-e", "--email EMAIL", "mite.user email") do |email|
|
21
23
|
@options["email"] = email
|
22
24
|
end
|
23
25
|
|
24
|
-
opts.on("-p", "--password
|
26
|
+
opts.on("-p", "--password PASSWORD", "mite.user password") do |password|
|
25
27
|
@options["password"] = password
|
26
28
|
end
|
27
29
|
|
30
|
+
opts.on(
|
31
|
+
"-w", "--wait-for SECONDS", Integer,
|
32
|
+
"Number of seconds to wait for backup to be ready. Defaults to 240 seconds."
|
33
|
+
) do |seconds|
|
34
|
+
@options["wait_for"] = seconds
|
35
|
+
end
|
36
|
+
|
28
37
|
opts.on("-c", "--clear", "Removes all config values from config file.") do
|
29
38
|
@options["clear_config"] = true
|
30
39
|
end
|
@@ -37,7 +46,7 @@ parser = OptionParser.new do |opts|
|
|
37
46
|
opts.separator ""
|
38
47
|
opts.separator "Commands:"
|
39
48
|
opts.separator " get Download backupfile and ouput xml to STDOUT (Default command)"
|
40
|
-
opts.separator " setup
|
49
|
+
opts.separator " setup Write given options to config file ~/.mite-backup.yml, so you don't need to repeat them on every get command."
|
41
50
|
opts.separator ""
|
42
51
|
end
|
43
52
|
|
@@ -53,4 +62,4 @@ else
|
|
53
62
|
puts ""
|
54
63
|
puts parser.help
|
55
64
|
exit(1)
|
56
|
-
end
|
65
|
+
end
|
data/lib/mite-backup.rb
CHANGED
@@ -6,7 +6,7 @@ require 'zlib'
|
|
6
6
|
require 'yaml'
|
7
7
|
|
8
8
|
class MiteBackup
|
9
|
-
|
9
|
+
DEFAULT_WAIT_FOR = 240 # seconds
|
10
10
|
SLEEP_BEFORE_EACH_CHECK = 5 # seconds
|
11
11
|
CONFIG_FILE = File.expand_path('~/.mite-backup.yml')
|
12
12
|
USER_AGENT = "mite-backup/#{MiteBackup::VERSION}"
|
@@ -17,6 +17,9 @@ class MiteBackup
|
|
17
17
|
@account = correct_account(options["account"] || config["account"])
|
18
18
|
@email = options["email"] || config["email"]
|
19
19
|
@password = options["password"] || config["password"]
|
20
|
+
@max_checks = options["wait_for"] != DEFAULT_WAIT_FOR ?
|
21
|
+
options["wait_for"] / SLEEP_BEFORE_EACH_CHECK :
|
22
|
+
config["wait_for"] || DEFAULT_WAIT_FOR
|
20
23
|
end
|
21
24
|
|
22
25
|
def run
|
@@ -30,6 +33,8 @@ class MiteBackup
|
|
30
33
|
(config["account"] = @account) || config.delete("account")
|
31
34
|
(config["email"] = @email) || config.delete("email")
|
32
35
|
(config["password"] = @password) || config.delete("password")
|
36
|
+
(config["wait_for"] = @options["wait_for"]) || config.delete("wait_for")
|
37
|
+
config.delete("wait_for") if config["wait_for"] == DEFAULT_WAIT_FOR
|
33
38
|
|
34
39
|
if config.size == 0
|
35
40
|
self.class.clear_config
|
@@ -59,7 +64,7 @@ class MiteBackup
|
|
59
64
|
end
|
60
65
|
|
61
66
|
def check
|
62
|
-
|
67
|
+
@max_checks.times do |i|
|
63
68
|
sleep(SLEEP_BEFORE_EACH_CHECK)
|
64
69
|
@ready = parse_json(perform_request(Net::HTTP::Get.new("/account/backup/#{@id}.json")))["ready"]
|
65
70
|
break if @ready
|
@@ -77,7 +82,7 @@ class MiteBackup
|
|
77
82
|
end
|
78
83
|
puts gz.read
|
79
84
|
else
|
80
|
-
failed "Backup was not ready for download after #{
|
85
|
+
failed "Backup was not ready for download after #{@options["wait_for"]} seconds. Contact the mite.support."
|
81
86
|
end
|
82
87
|
end
|
83
88
|
|
data/lib/mite-backup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mite-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|