backup_paradise 1.2.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of backup_paradise might be problematic. Click here for more details.

Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +231 -0
  3. data/backup_paradise.gemspec +51 -0
  4. data/bin/backup_paradise +7 -0
  5. data/doc/README.gen +214 -0
  6. data/doc/TODO.md +221 -0
  7. data/lib/backup_paradise.rb +5 -0
  8. data/lib/backup_paradise/advanced_backup/advanced_backup.rb +53 -0
  9. data/lib/backup_paradise/advanced_backup/audio.rb +124 -0
  10. data/lib/backup_paradise/advanced_backup/constants.rb +34 -0
  11. data/lib/backup_paradise/advanced_backup/data_directory.rb +50 -0
  12. data/lib/backup_paradise/advanced_backup/do_perform_the_backup_tasks.rb +95 -0
  13. data/lib/backup_paradise/advanced_backup/initialize.rb +38 -0
  14. data/lib/backup_paradise/advanced_backup/menu.rb +280 -0
  15. data/lib/backup_paradise/advanced_backup/misc.rb +836 -0
  16. data/lib/backup_paradise/advanced_backup/reset.rb +56 -0
  17. data/lib/backup_paradise/advanced_backup/run.rb +26 -0
  18. data/lib/backup_paradise/advanced_backup/system_directory.rb +35 -0
  19. data/lib/backup_paradise/base/base.rb +440 -0
  20. data/lib/backup_paradise/base/colours.rb +123 -0
  21. data/lib/backup_paradise/base/constants.rb +16 -0
  22. data/lib/backup_paradise/constants/constants.rb +192 -0
  23. data/lib/backup_paradise/gui/gtk2/backup.rb +345 -0
  24. data/lib/backup_paradise/gui/gtk3/backup.rb +383 -0
  25. data/lib/backup_paradise/project/project_base_directory.rb +22 -0
  26. data/lib/backup_paradise/requires/require_the_backup_paradise_project.rb +14 -0
  27. data/lib/backup_paradise/tab/tab.rb +84 -0
  28. data/lib/backup_paradise/toplevel_methods/cliner.rb +16 -0
  29. data/lib/backup_paradise/toplevel_methods/colours.rb +80 -0
  30. data/lib/backup_paradise/toplevel_methods/e.rb +16 -0
  31. data/lib/backup_paradise/toplevel_methods/help.rb +88 -0
  32. data/lib/backup_paradise/toplevel_methods/misc.rb +343 -0
  33. data/lib/backup_paradise/toplevel_methods/mountpoint.rb +80 -0
  34. data/lib/backup_paradise/toplevel_methods/opnn.rb +21 -0
  35. data/lib/backup_paradise/version/version.rb +19 -0
  36. data/lib/backup_paradise/yaml/config.yml +22 -0
  37. metadata +178 -0
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/advanced_backup/reset.rb'
6
+ # =========================================================================== #
7
+ module BackupParadise
8
+
9
+ class AdvancedBackup < ::BackupParadise::Base # === BackupParadise::AdvancedBackup
10
+
11
+ # ========================================================================= #
12
+ # === reset
13
+ # ========================================================================= #
14
+ def reset
15
+ super()
16
+ # ======================================================================= #
17
+ # === @perform_backup
18
+ #
19
+ # The next variable determines whether we will perform a backup
20
+ # job or not. By default this will be false - it will be set
21
+ # to true by default through the menu() interface, via its
22
+ # else clause.
23
+ # ======================================================================= #
24
+ @perform_backup = false
25
+ # ======================================================================= #
26
+ # === @date
27
+ # ======================================================================= #
28
+ @date = dd_mm_yyyy
29
+ # ======================================================================= #
30
+ # === @use_this_as_timestamp
31
+ #
32
+ # The next variable will keep the timestamp as-is.
33
+ #
34
+ # This may include ':' characters, which Windows NTFS does not seem
35
+ # to like. Thus, since as of September 2020, a slightly simpler
36
+ # variant is used here.
37
+ # ======================================================================= #
38
+ @use_this_as_timestamp = "#{@date}-#{current_time.tr(':','_')}"
39
+ # ======================================================================= #
40
+ # === @array_store_times
41
+ #
42
+ # The next Array will keep track of how long it took to backup
43
+ # the data.
44
+ # ======================================================================= #
45
+ @array_store_times = []
46
+ # ======================================================================= #
47
+ # === @show_popup_notification
48
+ # ======================================================================= #
49
+ @show_popup_notification = CONFIG['show_popup_notification']
50
+ # ======================================================================= #
51
+ # === @last_backup_directory
52
+ # ======================================================================= #
53
+ @last_backup_directory = nil
54
+ end
55
+
56
+ end; end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/advanced_backup/run.rb'
6
+ # =========================================================================== #
7
+ module BackupParadise
8
+
9
+ class AdvancedBackup < ::BackupParadise::Base # === BackupParadise::AdvancedBackup
10
+
11
+ # ========================================================================= #
12
+ # === run
13
+ # ========================================================================= #
14
+ def run
15
+ # ======================================================================= #
16
+ # The next method will determine the main mountpoint in use, such as
17
+ # "/Mount/USB1/".
18
+ # ======================================================================= #
19
+ determine_the_target_mountpoint
20
+ menu
21
+ if @perform_backup
22
+ do_perform_the_backup_tasks # ← This is the main method of this class.
23
+ end
24
+ end
25
+
26
+ end; end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/advanced_backup/system_directory.rb'
6
+ # =========================================================================== #
7
+ module BackupParadise
8
+
9
+ class AdvancedBackup < ::BackupParadise::Base # === BackupParadise::AdvancedBackup
10
+
11
+ # ========================================================================= #
12
+ # === backup_the_system_directory
13
+ #
14
+ # This method can be used to backup the "/System/Settings/" directory,
15
+ # as it may be found in GoboLinux.
16
+ # ========================================================================= #
17
+ def backup_the_system_directory(
18
+ target_directory = SYSTEM_SETTINGS_DIRECTORY
19
+ )
20
+ if File.directory? target_directory
21
+ cliner
22
+ e 'Now backing up the system-settings directory from '+
23
+ sfancy(target_directory)+' into '+
24
+ sfile(main_target?+File.basename(target_directory))
25
+ cliner
26
+ report_total_size_of(target_directory)
27
+ backup_this_directory_if_it_exists(
28
+ target_directory, :default, :do_not_continue
29
+ )
30
+ else
31
+ can_not_backup_this_directory_as_it_does_not_exist(target_directory)
32
+ end
33
+ end; alias backup_system_directory backup_the_system_directory # === backup_system_directory
34
+
35
+ end; end
@@ -0,0 +1,440 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/base/base.rb'
6
+ # =========================================================================== #
7
+ require 'backup_paradise/base/colours.rb'
8
+ require 'backup_paradise/base/constants.rb'
9
+ require 'backup_paradise/constants/constants.rb'
10
+ require 'backup_paradise/toplevel_methods/cliner.rb'
11
+ require 'backup_paradise/toplevel_methods/colours.rb'
12
+ require 'backup_paradise/toplevel_methods/e.rb'
13
+ require 'backup_paradise/toplevel_methods/misc.rb'
14
+ require 'backup_paradise/toplevel_methods/mountpoint.rb'
15
+ require 'backup_paradise/tab/tab.rb'
16
+ require 'backup_paradise/project/project_base_directory.rb'
17
+
18
+ module BackupParadise
19
+
20
+ class Base
21
+
22
+ # ========================================================================= #
23
+ # Next, external code is loaded.
24
+ # ========================================================================= #
25
+ begin
26
+ require 'roebe/time/time.rb'
27
+ rescue LoadError; end
28
+
29
+ begin
30
+ require 'opn'
31
+ rescue LoadError; end
32
+
33
+ # ========================================================================= #
34
+ # === BackupParadise.e
35
+ # ========================================================================= #
36
+ def e(i = '')
37
+ BackupParadise.e(i)
38
+ end
39
+
40
+ # ========================================================================= #
41
+ # === all_important_directories?
42
+ # ========================================================================= #
43
+ def all_important_directories?
44
+ ARRAY_THE_FIVE_MAIN_ENTRIES
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === reset
49
+ # ========================================================================= #
50
+ def reset
51
+ @use_this_program_to_rename_tabs = nil
52
+ end
53
+
54
+ # ========================================================================= #
55
+ # === home_dir_of_user_x?
56
+ # ========================================================================= #
57
+ def home_dir_of_user_x?
58
+ '/home/x/'
59
+ end
60
+
61
+ # ========================================================================= #
62
+ # === use_colours?
63
+ # ========================================================================= #
64
+ def use_colours?
65
+ BackupParadise.use_colours?
66
+ end
67
+
68
+ # ========================================================================= #
69
+ # === n_files_in?
70
+ #
71
+ # This method will return how many files are in the given directory.
72
+ # ========================================================================= #
73
+ def n_files_in?(i)
74
+ _ = 0
75
+ if File.directory? i
76
+ _ = Dir["#{i}*"].size
77
+ end
78
+ _
79
+ end
80
+
81
+ # ========================================================================= #
82
+ # === create_directory
83
+ #
84
+ # The first argument to this method should be the name of the directory
85
+ # that has to be created, such as 'foobar/'.
86
+ # ========================================================================= #
87
+ def create_directory(
88
+ i, options = { mode_to_use: 0755 }
89
+ )
90
+ BackupParadise.create_directory(i, options)
91
+ end; alias mkdir create_directory # === mkdir
92
+
93
+ # ========================================================================= #
94
+ # === rds
95
+ # ========================================================================= #
96
+ def rds(i)
97
+ BackupParadise.rds(i)
98
+ end
99
+
100
+ # ========================================================================= #
101
+ # === no_such_directory_exists_at
102
+ # ========================================================================= #
103
+ def no_such_directory_exists_at(i)
104
+ e "No such directory exists at `#{sdir(i)}`."
105
+ end
106
+
107
+ # ========================================================================= #
108
+ # === cliner
109
+ # ========================================================================= #
110
+ def cliner
111
+ BackupParadise.cliner
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === no_target_at
116
+ # ========================================================================= #
117
+ def no_target_at(i)
118
+ e "No target at #{sfile(i)} could be found."
119
+ end
120
+
121
+ # ========================================================================= #
122
+ # === target_hdd_does_not_have_enough_space_left?
123
+ # ========================================================================= #
124
+ def target_hdd_does_not_have_enough_space_left?
125
+ false # for now this is always false. stub
126
+ # MINIMAL_FILESIZE
127
+ end
128
+
129
+ # ========================================================================= #
130
+ # === opnn
131
+ # ========================================================================= #
132
+ def opnn(i = NAMESPACE)
133
+ if i.is_a? String
134
+ i = {
135
+ namespace: i,
136
+ use_colours: use_colours?
137
+ }
138
+ end
139
+ BackupParadise.opnn(i)
140
+ end
141
+
142
+ # ========================================================================= #
143
+ # === delete_symlink
144
+ # ========================================================================= #
145
+ def delete_symlink(i)
146
+ if File.symlink? i
147
+ File.delete(i)
148
+ end
149
+ end
150
+
151
+ # ========================================================================= #
152
+ # === has_superuser_abilities?
153
+ # ========================================================================= #
154
+ def has_superuser_abilities?
155
+ Process.uid.zero?
156
+ end
157
+
158
+ # ========================================================================= #
159
+ # === chdir (cd tag)
160
+ #
161
+ # Change directory via this method here.
162
+ # ========================================================================= #
163
+ def chdir(i)
164
+ BackupParadise.change_directory(i)
165
+ end; alias cd chdir # === cd
166
+ alias change_directory chdir # === change_directory
167
+
168
+ # ========================================================================= #
169
+ # === cd_to_the_mounted_device
170
+ # ========================================================================= #
171
+ def cd_to_the_mounted_device
172
+ cd target_mountpoint?
173
+ end
174
+
175
+ # ========================================================================= #
176
+ # === do_symlink
177
+ # ========================================================================= #
178
+ def do_symlink(
179
+ from_this_target, create_a_symlink_here
180
+ )
181
+ if File.exist? create_a_symlink_here
182
+ no_target_at(create_a_symlink_here)
183
+ else
184
+ File.symlink(from_this_target, create_a_symlink_here)
185
+ end
186
+ end
187
+
188
+ # ========================================================================= #
189
+ # === delete_files
190
+ # ========================================================================= #
191
+ def delete_files(
192
+ i, be_verbose = false
193
+ )
194
+ case be_verbose
195
+ when :be_verbose
196
+ be_verbose = true
197
+ end
198
+ if i.is_a? Array
199
+ i.each {|entry| delete_files(entry, be_verbose) }
200
+ else
201
+ if File.file? i
202
+ if be_verbose
203
+ opnn; e "Now deleting the file `#{sfile(i)}`."
204
+ end
205
+ File.delete(i)
206
+ else
207
+ e sfancy(i)+' is not not a file - we thus can not delete it.'
208
+ end
209
+ end
210
+ end; alias delete_file delete_files # === delete_file
211
+ alias remove_these_files delete_files # === remove_these_files
212
+
213
+ # ========================================================================= #
214
+ # === remove_directory
215
+ # ========================================================================= #
216
+ def remove_directory(i)
217
+ BackupParadise.remove_directory(i)
218
+ end
219
+
220
+ # ========================================================================= #
221
+ # === register_sigint
222
+ # ========================================================================= #
223
+ def register_sigint
224
+ Signal.trap('SIGINT') { exit_program }
225
+ end
226
+
227
+ # ========================================================================= #
228
+ # === copy_file
229
+ # ========================================================================= #
230
+ def copy_file(from, to)
231
+ BackupParadise.copy_file(from, to)
232
+ end; alias copy_this_file copy_file # === copy_this_file
233
+
234
+ begin
235
+ require 'roebe/toplevel_methods/write_what_into.rb'
236
+ rescue LoadError => error
237
+ puts 'Please install the roebe-gem ( gem install roebe ).'
238
+ pp error
239
+ end
240
+
241
+ # ========================================================================= #
242
+ # === write_what_into
243
+ # ========================================================================= #
244
+ def write_what_into(what, into)
245
+ ::Roebe.write_what_into(what, into)
246
+ end
247
+
248
+ # ========================================================================= #
249
+ # === append_what_into
250
+ # ========================================================================= #
251
+ def append_what_into(what, into)
252
+ ::Roebe.append_what_into(what, into)
253
+ end
254
+
255
+ # ========================================================================= #
256
+ # === remove
257
+ # ========================================================================= #
258
+ def remove(i)
259
+ BackupParadise.remove(i)
260
+ end
261
+
262
+ # ========================================================================= #
263
+ # === data_directory?
264
+ # ========================================================================= #
265
+ def data_directory?
266
+ DATA_DIRECTORY
267
+ end; alias data_dir? data_directory? # === data_dir?
268
+
269
+ # ========================================================================= #
270
+ # === dd_mm_yyyy
271
+ #
272
+ # This method will return a String such as "25.12.2018".
273
+ # ========================================================================= #
274
+ def dd_mm_yyyy
275
+ ::Roebe::Time.dd_mm_yyyy # Tap into the Roebe namespace for this.
276
+ end
277
+
278
+ # ========================================================================= #
279
+ # === return_current_date_and_time
280
+ #
281
+ # This method will return a String such as:
282
+ #
283
+ # "24.05.2018-03:48:50"
284
+ #
285
+ # ========================================================================= #
286
+ def return_current_date_and_time
287
+ "#{dd_mm_yyyy}-#{hh_mm_ss}"
288
+ end; alias return_full_date return_current_date_and_time # === return_full_date
289
+ alias date_and_time? return_current_date_and_time # === date_and_time?
290
+
291
+ # ========================================================================= #
292
+ # === size?
293
+ # ========================================================================= #
294
+ def size?(i)
295
+ BackupParadise.size?(i)
296
+ end
297
+
298
+ # ========================================================================= #
299
+ # === no_file_exists_at
300
+ # ========================================================================= #
301
+ def no_file_exists_at(i)
302
+ e "No file exists at `#{sfile(i)}`."
303
+ end
304
+
305
+ # ========================================================================= #
306
+ # === exit_program (exit tag)
307
+ #
308
+ # This method should be used when we have to exit from the
309
+ # backup_paradise project.
310
+ #
311
+ # The reason why a separate exit-method has been added is so that we
312
+ # can change this at a later time possibly, if we wish to do further
313
+ # checks before exiting.
314
+ # ========================================================================= #
315
+ def exit_program(be_verbose = false)
316
+ if be_verbose
317
+ e 'Quit was called, thus we exit now.'
318
+ end
319
+ if @use_this_program_to_rename_tabs
320
+ rename_tab(@use_this_program_to_rename_tabs)
321
+ end
322
+ exit
323
+ end
324
+
325
+ # ========================================================================= #
326
+ # === target_mountpoint?
327
+ #
328
+ # Designate to which target we will backup.
329
+ # ========================================================================= #
330
+ def target_mountpoint?
331
+ BackupParadise.target_mountpoint?
332
+ end; alias main_target? target_mountpoint? # === main_target?
333
+ alias backup_to_this_directory? target_mountpoint? # === backup_to_this_directory?
334
+ alias mount_point? target_mountpoint? # === mount_point?
335
+ alias mount_target? target_mountpoint? # === mount_target?
336
+
337
+ # ========================================================================= #
338
+ # === report_total_size_of
339
+ #
340
+ # Use this method to report the total size of a specific directory. We
341
+ # expect the input to this method thus be a (local) directory.
342
+ # ========================================================================= #
343
+ def report_total_size_of(i)
344
+ size_result = size?(i)
345
+ kb_size = (size_result.to_f / 1000.0).round(2)
346
+ mb_size = (kb_size.to_f / 1000.0).round(2)
347
+ gb_size = (mb_size.to_f / 1000.0).round(2)
348
+ e 'Total size of files in bytes at '+sdir(i)+': '+
349
+ seagreen(size_result)+' bytes.'
350
+ e 'This corresponds to '+
351
+ orangered(kb_size.to_s)+lightcoral(' KB ')+
352
+ orangered(mb_size.to_s)+lightcoral(' MB ')+
353
+ orangered(gb_size.to_s)+lightcoral(' GB')+'.'
354
+ end; alias report_file_size_of report_total_size_of # === report_file_size_of
355
+
356
+ # ========================================================================= #
357
+ # === rename
358
+ # ========================================================================= #
359
+ def rename(a, b)
360
+ if File.exist? b
361
+ e "Can not rename to #{sfancy(b)} as that target already exists."
362
+ else
363
+ FileUtils.mv(a, b)
364
+ end
365
+ end
366
+
367
+ # ========================================================================= #
368
+ # === copy_recursively
369
+ # ========================================================================= #
370
+ def copy_recursively(
371
+ source,
372
+ target,
373
+ be_verbose = :be_verbose
374
+ )
375
+ BackupParadise.copy_recursively(
376
+ source, target, be_verbose
377
+ )
378
+ end; alias cpr copy_recursively # === cpr
379
+
380
+ # ========================================================================= #
381
+ # === rename_tab
382
+ #
383
+ # This method can be used to rename the tab of e. g. mrxvt or KDE konsole.
384
+ # ========================================================================= #
385
+ def rename_tab(
386
+ use_this_terminal = :konsole, # or :mrxvt
387
+ use_this_as_new_title = 'Hello world!'
388
+ )
389
+ BackupParadise::Tab.rename_tab(
390
+ use_this_terminal,
391
+ use_this_as_new_title
392
+ )
393
+ end
394
+
395
+ # ========================================================================= #
396
+ # === set_target_mountpoint
397
+ # ========================================================================= #
398
+ def set_target_mountpoint(i)
399
+ i = i.to_s
400
+ case i
401
+ # ======================================================================= #
402
+ # Specify some shortcuts to be used here.
403
+ # ======================================================================= #
404
+ when '1',
405
+ '2',
406
+ '3',
407
+ '4',
408
+ '5',
409
+ '6',
410
+ '7',
411
+ '8',
412
+ '9',
413
+ 'usb1',
414
+ 'usb2',
415
+ 'usb3',
416
+ 'usb4',
417
+ 'usb5',
418
+ 'usb6'
419
+ i = i.dup if i.frozen?
420
+ if i.start_with? 'usb'
421
+ i.sub!(/^usb/,'')
422
+ elsif i.start_with? 'to'
423
+ i.sub!(/^to(-| |_)?usb/,'')
424
+ end
425
+ i = "/Mount/USB#{i}/"
426
+ end
427
+ BackupParadise.target_mountpoint = i
428
+ end; alias set_target_device set_target_mountpoint # === set_target_device
429
+ alias set_backup_to_this_directory set_target_mountpoint # === set_backup_to_this_directory
430
+ alias set_target set_target_mountpoint # === set_target
431
+ alias set_main_target set_target_mountpoint # === set_main_target
432
+
433
+ # ========================================================================= #
434
+ # === hh_mm_ss
435
+ # ========================================================================= #
436
+ def hh_mm_ss
437
+ ::Roebe::Time.hh_mm_ss # This will yield something like: "03:53:55"
438
+ end; alias current_time hh_mm_ss # === current_time
439
+
440
+ end; end