backup_restore 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/backup_restore.rb +19 -5
  3. metadata +18 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 73d6a97ad9149c56583f79c36e52646b3f7d4909
4
- data.tar.gz: fb48eb5f6253a6c0d4b9ca317837f39967375f8b
2
+ SHA256:
3
+ metadata.gz: 613b9269f9ac596c48d435acea0104daaeb5a77e7b3de9bd3a269a1e08c11a07
4
+ data.tar.gz: 7c3621da53ccff81bb257df6d5353e6f0900a658230b6edb134cca8cca9c46c2
5
5
  SHA512:
6
- metadata.gz: a7060946605d852ef91dc94339a575459c6c581ea0e2235a4f906a6df74a4ab2136bef21a48dad35d7374d8f669408cc322e7fd24e00d79537dea24f5033ee2b
7
- data.tar.gz: f00526513aa3cbc398962c45758fa4b788dc5b2bd984170d6732adae78ea90c95aeedcbe829478e29692cfee0679df019dee3553650c04e12630435daa50af56
6
+ metadata.gz: be1f6ff91000c35702118ee9092e71e5a902b6f1d713aef8a56cb007c20a79b2b21980ac99327784995fa6e1c03e435f8ac04ede663e8a5b4e8c62c42d7dc754
7
+ data.tar.gz: e6e306071341fa77f7c6e5b1378bc40759dae01d576bd0c73eaff0af08b9e83328eb930949655df37b59bd68d9454ef297f72aa48902cbc67f65ef80fe25ee99
@@ -57,7 +57,7 @@ class BackupRestore
57
57
  def self.extract_tar_file(file, target_folder = nil)
58
58
  command = "tar --extract --file=#{file}"
59
59
  unless target_folder.nil?
60
- command += " --preserve-permissions -C #{target_folder}"
60
+ command += " --preserve-permissions -C '#{target_folder}'"
61
61
  # -C
62
62
  # tar will change its current directory to dir before performing any operations
63
63
  # https://www.gnu.org/software/tar/manual/html_node/Option-Summary.html
@@ -92,7 +92,7 @@ class BackupRestore
92
92
  storage = get_storage_folder(archive_storage_root, archive_name)
93
93
  output_archive = archive_name + '.tar'
94
94
  change_directory(storage)
95
- command = "openssl aes-256-cbc -d -in #{archive_name}.tar.enc -k #{password} -out #{output_archive}"
95
+ command = "openssl aes-256-cbc -md md5 -d -in '#{archive_name}.tar.enc' -k '#{password}' -out '#{output_archive}'"
96
96
  execute_command(command)
97
97
  end
98
98
 
@@ -126,7 +126,8 @@ class BackupRestore
126
126
  def self.unsplit_archive(archive_storage_root, archive_name)
127
127
  storage = get_storage_folder(archive_storage_root, archive_name)
128
128
  change_directory(storage)
129
- execute_command("cat #{archive_name}.tar.enc-* > #{archive_name}.tar.enc")
129
+ raise "archive name was assumed to not have spaces but it is #{archive_name}" if archive_name.include?(" ")
130
+ execute_command("cat #{archive_name}.tar.enc-* > '#{archive_name}.tar.enc'")
130
131
  end
131
132
 
132
133
  def self.validate_folder_parameters(archive_storage_root, unpack_root)
@@ -139,15 +140,28 @@ class BackupRestore
139
140
  def self.process_given_archive(archive_storage_root, archive_name, unpack_root, password)
140
141
  debug("processsing #{archive_name} in #{archive_storage_root} - extracting to #{unpack_root}", :high)
141
142
  validate_folder_parameters(archive_storage_root, unpack_root)
143
+ # archive may be in form of
144
+ # (1) file(s) $NAME.tar.enc-aaa, $NAME.tar.enc-aab, $NAME.tar.enc-aac ...
145
+ # (2) single $NAME.tar.enc
142
146
  if is_unsplitting_necessary(archive_storage_root, archive_name)
143
147
  unsplit_archive(archive_storage_root, archive_name)
144
148
  end
149
+
150
+ # now $NAME.tar.enc exists with the entire archive
145
151
  uncrypt_archive(archive_storage_root, archive_name, password)
146
- extract_archive(archive_storage_root, archive_name, unpack_root)
147
- storage = get_storage_folder(archive_storage_root, archive_name)
152
+ # now $NAME.tar exists with the entire archive unencrypted
153
+
154
+ # now $NAME.tar.enc can be now deleted if it was created
155
+ # it MUST NOT be deleted if archive was not split - in that case
156
+ # it is the original archive file!
157
+ # it is deleted at this step to reduce peak memory consumption on disk
158
+ # for unpacking large archives
148
159
  if is_unsplitting_necessary(archive_storage_root, archive_name)
149
160
  FileUtils.rm_rf(storage + archive_name + ".tar.enc")
150
161
  end
162
+
163
+ extract_archive(archive_storage_root, archive_name, unpack_root)
164
+ storage = get_storage_folder(archive_storage_root, archive_name)
151
165
  FileUtils.rm_rf(storage + archive_name + ".tar")
152
166
  end
153
167
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup_restore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Konieczny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-16 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2019-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: matkoniecz-ruby-style
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: 'Script for unpacking backups produced by the backup gem. See https://github.com/backup/backup-features/issues/28
14
28
  for discussion about this feature in backup gem itself. '
15
29
  email: matkoniecz@gmail.com
@@ -37,8 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
51
  - !ruby/object:Gem::Version
38
52
  version: '0'
39
53
  requirements: []
40
- rubyforge_project:
41
- rubygems_version: 2.5.1
54
+ rubygems_version: 3.0.4
42
55
  signing_key:
43
56
  specification_version: 4
44
57
  summary: Script for unpacking backups produced by the backup gem.