backup_restore 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/backup_restore.rb +11 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73d6a97ad9149c56583f79c36e52646b3f7d4909
|
4
|
+
data.tar.gz: fb48eb5f6253a6c0d4b9ca317837f39967375f8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7060946605d852ef91dc94339a575459c6c581ea0e2235a4f906a6df74a4ab2136bef21a48dad35d7374d8f669408cc322e7fd24e00d79537dea24f5033ee2b
|
7
|
+
data.tar.gz: f00526513aa3cbc398962c45758fa4b788dc5b2bd984170d6732adae78ea90c95aeedcbe829478e29692cfee0679df019dee3553650c04e12630435daa50af56
|
data/lib/backup_restore.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# Encoding: utf-8
|
2
|
-
|
3
1
|
# Copyright (C) 2016 - GPLv3 - Mateusz Konieczny
|
4
2
|
|
5
3
|
require 'io/console'
|
@@ -12,6 +10,8 @@ require 'fileutils'
|
|
12
10
|
# archives may be split or not
|
13
11
|
|
14
12
|
class BackupRestore
|
13
|
+
class PreconditionFailed < StandardError
|
14
|
+
end
|
15
15
|
def self.debug(message, priority = :medium)
|
16
16
|
return if priority == :low
|
17
17
|
return if priority == :medium
|
@@ -129,8 +129,16 @@ class BackupRestore
|
|
129
129
|
execute_command("cat #{archive_name}.tar.enc-* > #{archive_name}.tar.enc")
|
130
130
|
end
|
131
131
|
|
132
|
+
def self.validate_folder_parameters(archive_storage_root, unpack_root)
|
133
|
+
raise PreconditionFailed.new("archive_storage_root (<#{archive_storage_root}>) does not exists") if !File.exist?(archive_storage_root)
|
134
|
+
raise PreconditionFailed.new("unpack_root (<#{unpack_root}>) does not exists") if !File.exist?(unpack_root)
|
135
|
+
raise PreconditionFailed.new("archive_storage_root (<#{archive_storage_root}>) is a file, not directory") if !Dir.exist?(archive_storage_root)
|
136
|
+
raise PreconditionFailed.new("unpack_root (<#{unpack_root}>) is a file, not directory") if !Dir.exist?(unpack_root)
|
137
|
+
end
|
138
|
+
|
132
139
|
def self.process_given_archive(archive_storage_root, archive_name, unpack_root, password)
|
133
140
|
debug("processsing #{archive_name} in #{archive_storage_root} - extracting to #{unpack_root}", :high)
|
141
|
+
validate_folder_parameters(archive_storage_root, unpack_root)
|
134
142
|
if is_unsplitting_necessary(archive_storage_root, archive_name)
|
135
143
|
unsplit_archive(archive_storage_root, archive_name)
|
136
144
|
end
|
@@ -218,15 +226,4 @@ class BackupRestore
|
|
218
226
|
def self.everything_is_fine_message
|
219
227
|
return "everything is fine!" + "\n"
|
220
228
|
end
|
221
|
-
|
222
|
-
def self.directory_size(path)
|
223
|
-
size = 0
|
224
|
-
Dir.glob(File.join(path, '**', '*')) { |file| size += File.size(file) }
|
225
|
-
return size
|
226
|
-
end
|
227
|
-
|
228
|
-
def self.is_it_at_least_this_size_in_mb(path, mb)
|
229
|
-
size = directory_size(path)
|
230
|
-
return size > mb * 1024 * 1024
|
231
|
-
end
|
232
|
-
end
|
229
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backup_restore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Konieczny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Script for unpacking backups produced by the backup gem. See https://github.com/backup/backup-features/issues/28
|
14
14
|
for discussion about this feature in backup gem itself. '
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.
|
41
|
+
rubygems_version: 2.5.1
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Script for unpacking backups produced by the backup gem.
|