backup_paradise 1.2.37

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.

Potentially problematic release.


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

Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +375 -0
  3. data/backup_paradise.gemspec +50 -0
  4. data/bin/backup_for_ingrid +10 -0
  5. data/bin/backup_paradise +7 -0
  6. data/bin/windows_backup_paradise +9 -0
  7. data/doc/README.gen +347 -0
  8. data/doc/TODO.md +130 -0
  9. data/lib/backup_paradise/actions/README.md +2 -0
  10. data/lib/backup_paradise/actions/backup.rb +62 -0
  11. data/lib/backup_paradise/base/base.rb +493 -0
  12. data/lib/backup_paradise/base/colours.rb +137 -0
  13. data/lib/backup_paradise/base/namespace.rb +16 -0
  14. data/lib/backup_paradise/base/tab.rb +47 -0
  15. data/lib/backup_paradise/colours/colours.rb +88 -0
  16. data/lib/backup_paradise/constants/constants.rb +162 -0
  17. data/lib/backup_paradise/gui/glimmer/libui/backup_for_ingrid/backup_for_ingrid.rb +87 -0
  18. data/lib/backup_paradise/gui/gtk2/OLD_backup.rb +222 -0
  19. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/create.rb +64 -0
  20. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/misc.rb +34 -0
  21. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/simple_backup_widget.rb +167 -0
  22. data/lib/backup_paradise/gui/libui/backup_for_ingrid/backup_for_ingrid.rb +99 -0
  23. data/lib/backup_paradise/gui/libui/simple_backup_widget/simple_backup_widget.rb +119 -0
  24. data/lib/backup_paradise/gui/shared_code/simple_backup_widget/simple_backup_widget_module.rb +595 -0
  25. data/lib/backup_paradise/gui/tk/backup.rb +108 -0
  26. data/lib/backup_paradise/images/BACKUP_IMAGE.png +0 -0
  27. data/lib/backup_paradise/images/right_arrow.png +0 -0
  28. data/lib/backup_paradise/project/project.rb +40 -0
  29. data/lib/backup_paradise/requires/require_the_backup_paradise_project.rb +18 -0
  30. data/lib/backup_paradise/requires/require_yaml.rb +7 -0
  31. data/lib/backup_paradise/tab/tab.rb +87 -0
  32. data/lib/backup_paradise/toplevel_methods/cliner.rb +16 -0
  33. data/lib/backup_paradise/toplevel_methods/config.rb +77 -0
  34. data/lib/backup_paradise/toplevel_methods/create_and_remove.rb +63 -0
  35. data/lib/backup_paradise/toplevel_methods/e.rb +16 -0
  36. data/lib/backup_paradise/toplevel_methods/esystem.rb +19 -0
  37. data/lib/backup_paradise/toplevel_methods/files_and_directories.rb +181 -0
  38. data/lib/backup_paradise/toplevel_methods/help.rb +93 -0
  39. data/lib/backup_paradise/toplevel_methods/misc.rb +153 -0
  40. data/lib/backup_paradise/toplevel_methods/mountpoint.rb +185 -0
  41. data/lib/backup_paradise/toplevel_methods/opnn.rb +25 -0
  42. data/lib/backup_paradise/utility_scripts/backup/backup.rb +1389 -0
  43. data/lib/backup_paradise/utility_scripts/backup/constants.rb +34 -0
  44. data/lib/backup_paradise/utility_scripts/backup/initialize.rb +71 -0
  45. data/lib/backup_paradise/utility_scripts/backup/menu.rb +360 -0
  46. data/lib/backup_paradise/utility_scripts/backup/run.rb +20 -0
  47. data/lib/backup_paradise/version/version.rb +19 -0
  48. data/lib/backup_paradise/windows/README.md +1 -0
  49. data/lib/backup_paradise/windows/windows.rb +101 -0
  50. data/lib/backup_paradise/www/backup.cgi +63 -0
  51. data/lib/backup_paradise/yaml/config.yml +78 -0
  52. data/lib/backup_paradise.rb +5 -0
  53. data/test/testing_toplevel_functionality.rb +11 -0
  54. metadata +198 -0
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/utility_scripts/backup/constants.rb'
6
+ # =========================================================================== #
7
+ require 'backup_paradise/base/base.rb'
8
+
9
+ module BackupParadise
10
+
11
+ class Backup < ::BackupParadise::Base
12
+
13
+ # ========================================================================= #
14
+ # === NAMESPACE
15
+ # ========================================================================= #
16
+ NAMESPACE = inspect
17
+
18
+ # ========================================================================= #
19
+ # === MINIMAL_FILESIZE
20
+ # ========================================================================= #
21
+ MINIMAL_FILESIZE = 5 * (1000 ** 3) # 5 * 1024 * 1024 * 1024
22
+
23
+ # ========================================================================= #
24
+ # === FILE_BACKUP_LOG
25
+ #
26
+ # Denote where to keep the backup.log file, if we log that is.
27
+ # ========================================================================= #
28
+ if File.directory? '/home/Temp/'
29
+ FILE_BACKUP_LOG = '/home/Temp/backup.log'
30
+ else
31
+ FILE_BACKUP_LOG = '/tmp/backup.log'
32
+ end
33
+
34
+ end; end
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/utility_scripts/backup/initialize.rb'
6
+ # =========================================================================== #
7
+ require 'backup_paradise/base/base.rb'
8
+
9
+ module BackupParadise
10
+
11
+ class Backup < ::BackupParadise::Base # === BackupParadise::Backup
12
+
13
+ # ========================================================================= #
14
+ # === initialize
15
+ #
16
+ # Invocation example:
17
+ #
18
+ # x = BackupParadise::Backup.new(nil, :do_not_run_yet)
19
+ #
20
+ # ========================================================================= #
21
+ def initialize(
22
+ commandline_arguments = nil,
23
+ run_already = true,
24
+ &block
25
+ )
26
+ register_sigint
27
+ reset
28
+ if commandline_arguments
29
+ if commandline_arguments.is_a?(Symbol)
30
+ case commandline_arguments
31
+ # =================================================================== #
32
+ # === :do_not_run_yet
33
+ # =================================================================== #
34
+ when :do_not_run_yet
35
+ run_already = false
36
+ end
37
+ else
38
+ set_commandline_arguments(
39
+ commandline_arguments
40
+ )
41
+ end
42
+ end
43
+ case run_already
44
+ # ======================================================================= #
45
+ # === :do_not_run_yet
46
+ # ======================================================================= #
47
+ when :do_not_run_yet
48
+ run_already = false
49
+ end
50
+ # ======================================================================= #
51
+ # === Handle blocks given next
52
+ # ======================================================================= #
53
+ if block_given?
54
+ yielded = yield
55
+ case yielded
56
+ # ===================================================================== #
57
+ # === :do_not_run_yet
58
+ # ===================================================================== #
59
+ when :do_not_run_yet
60
+ run_already = false
61
+ # ===================================================================== #
62
+ # === :we_are_on_windows
63
+ # ===================================================================== #
64
+ when :we_are_on_windows
65
+ @internal_hash[:are_we_on_windows] = true
66
+ end
67
+ end
68
+ run if run_already
69
+ end
70
+
71
+ end; end
@@ -0,0 +1,360 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/utility_scripts/backup/menu.rb'
6
+ # =========================================================================== #
7
+ require 'backup_paradise/base/base.rb'
8
+
9
+ module BackupParadise
10
+
11
+ class Backup < ::BackupParadise::Base # === BackupParadise::Backup
12
+
13
+ require 'backup_paradise/version/version.rb'
14
+
15
+ # ========================================================================= #
16
+ # === menu (menu tag)
17
+ # ========================================================================= #
18
+ def menu(
19
+ i = commandline_arguments?
20
+ )
21
+ return if i.nil?
22
+ # ======================================================================= #
23
+ # === Handle Hashes
24
+ #
25
+ # Note that this is the default entry point.
26
+ #
27
+ # An example for how this may be used is given next:
28
+ #
29
+ # BackupParadise::Actions.backup(
30
+ # backup_these_directories: i,
31
+ # where_to: to
32
+ # )
33
+ #
34
+ # ======================================================================= #
35
+ if i.is_a? Hash
36
+ # ===================================================================== #
37
+ # === :backup_to_this_target
38
+ #
39
+ # The next check must come early, on top.
40
+ # ===================================================================== #
41
+ # ===================================================================== #
42
+ # === :where_to
43
+ # ===================================================================== #
44
+ if i.has_key? :where_to
45
+ set_backup_to_this_target(i[:where_to])
46
+ elsif i.has_key? :backup_to_this_target
47
+ set_backup_to_this_target(i[:backup_to_this_target])
48
+ end
49
+ # ===================================================================== #
50
+ # === :commandline_arguments
51
+ # ===================================================================== #
52
+ if i.has_key? :commandline_arguments
53
+ menu(i[:commandline_arguments])
54
+ # ===================================================================== #
55
+ # === :backup_these_directories
56
+ # ===================================================================== #
57
+ elsif i.has_key? :backup_these_directories
58
+ menu(i[:backup_these_directories])
59
+ end
60
+ # ======================================================================= #
61
+ # === Handle Arrays
62
+ # ======================================================================= #
63
+ elsif i.is_a? Array
64
+ i.each {|entry| menu(entry) }
65
+ else
66
+ case i # case tag
67
+ # ===================================================================== #
68
+ # === rbackup --libui
69
+ # ===================================================================== #
70
+ when /^-?-?lib-?ui$/i,
71
+ /^-?-?gui2$/i
72
+ require 'backup_paradise/gui/libui/backup_for_ingrid/backup_for_ingrid.rb'
73
+ BackupParadise::GUI::LibUI::BackupForIngrid.new
74
+ exit
75
+ # ===================================================================== #
76
+ # === rbackup --gui
77
+ #
78
+ # Alternatively use rbackup --gtk3.
79
+ # ===================================================================== #
80
+ when /^-?-?gui$/i,
81
+ /^-?-?gtk3$/i,
82
+ /^-?-?gtk$/i,
83
+ /^-?-?gui1$/i
84
+ start_the_gtk3_bindings
85
+ do_not_perform_the_regular_backup_routine
86
+ # ===================================================================== #
87
+ # === rbackup --version?
88
+ # ===================================================================== #
89
+ when /^-?-?version\??$/i
90
+ e BackupParadise::VERSION
91
+ do_not_perform_the_regular_backup_routine
92
+ # ===================================================================== #
93
+ # === rbackup --are-we-on-windows?
94
+ # ===================================================================== #
95
+ when /^-?-?are(-| |_)?we(-| |_)?on(-| |_)?windows\??$/i
96
+ e rev+'Are we on windows? '+
97
+ steelblue(are_we_on_windows?.to_s)
98
+ do_not_perform_the_regular_backup_routine
99
+ # ===================================================================== #
100
+ # === rbackup --help
101
+ #
102
+ # The user can use this entry point to obtain helpful information in
103
+ # how to use this class, on the commandline.
104
+ # ===================================================================== #
105
+ when /help/i,
106
+ /^-?-?show(-| |_)?help$/i,
107
+ 'hel','he','h','?','*'
108
+ show_help
109
+ do_not_perform_the_regular_backup_routine
110
+ # ===================================================================== #
111
+ # === rbackup --video-dir
112
+ # ===================================================================== #
113
+ when /^-?-?video(-| |_)?dir$/i,
114
+ /^-?-?video(-| |_)?directory$/i,
115
+ /^-?-?video$/i
116
+ backup_the_video_directory
117
+ do_not_perform_the_regular_backup_routine
118
+ # ===================================================================== #
119
+ # === rbackup --books
120
+ #
121
+ # This entry point allows the user to backup the /home/x/books/
122
+ # directory.
123
+ # ===================================================================== #
124
+ when /^-?-?books$/i,
125
+ /^-?-?books(-| |_)?directory$/i
126
+ backup_the_books_directory
127
+ do_not_perform_the_regular_backup_routine
128
+ # ===================================================================== #
129
+ # === rbackup --source-dir
130
+ # === rbackup --source-directory
131
+ # === rbackup --source
132
+ # === rbackup --src-dir
133
+ # === rbackup --src
134
+ #
135
+ # This entry point allows the user to backup the /home/x/src/
136
+ # directory.
137
+ # ===================================================================== #
138
+ when /^-?-?source(-| |_)?dir$/i,
139
+ /^-?-?source(-| |_)?directory$/i,
140
+ /^-?-?source$/i,
141
+ /^-?-?src(-| |_)?dir$/i,
142
+ /^-?-?src$/i
143
+ backup_the_source_directory
144
+ do_not_perform_the_regular_backup_routine
145
+ # ===================================================================== #
146
+ # === rbackup --audio-dir
147
+ #
148
+ # This entry point can be used to specifically backup the
149
+ # audio-directory - that is, the local directory that
150
+ # contains all songs.
151
+ #
152
+ # Usage example:
153
+ #
154
+ # rbackup --audio-dir
155
+ #
156
+ # A more advanced invocation example is:
157
+ #
158
+ # rbackup --backup-to=/opt/ --audio-dir
159
+ #
160
+ # ===================================================================== #
161
+ when /^-?-?audio(-| |_)?dir$/i,
162
+ /^-?-?audio$/i,
163
+ /^-?-?aud$/i,
164
+ /^-?-?audi$/i,
165
+ /^-?-?aonly$/i,
166
+ /^-?-?audio(-| |_)?only$/i
167
+ determine_whether_the_target_harddisc_is_a_ntfs_system
168
+ backup_the_audio_directory
169
+ do_not_perform_the_regular_backup_routine
170
+ # ===================================================================== #
171
+ # === Backup all relevant entries to the chroot-directory
172
+ #
173
+ # This entry point is mostly used for my local Chroot directory. We
174
+ # will quickly backup the important files to that directory, which
175
+ # then allows us to cd into a better chroot-environment.
176
+ #
177
+ # Invocation examples:
178
+ #
179
+ # rbackup --chroot
180
+ # rbackup --to-chroot
181
+ #
182
+ # ===================================================================== #
183
+ when /^-?-?chroot$/i,
184
+ /^-?-?to(-| |_)?chroot$/i,
185
+ /^-?-?into(-| |_)?chroot$/i
186
+ backup_into_the_default_chroot_directory
187
+ do_not_perform_the_regular_backup_routine
188
+ # ===================================================================== #
189
+ # === rbackup --studium-dir
190
+ # === rbackup --studium-directory
191
+ # === rbackup --studium
192
+ #
193
+ # This entry point allows the user to backup the /home/x/studium/
194
+ # directory, by making use of the constant STUDIUM_DIRECTORY.
195
+ # ===================================================================== #
196
+ when /^-?-?studium(-| |_)?dir$/i,
197
+ /^-?-?studium(-| |_)?directory$/i,
198
+ /^-?-?studium$/i
199
+ backup_the_studium_directory
200
+ do_not_perform_the_regular_backup_routine
201
+ # ===================================================================== #
202
+ # === rbackup --data-dir
203
+ # ===================================================================== #
204
+ when /^-?-?data(-| |_)?dir$/i,
205
+ /^-?-?data(-| |_)?directory$/i,
206
+ /^-?-?data$/i,
207
+ /^-?-?ONLY(-| |_)?DATA$/i,
208
+ /^-?-?DATA(-| |_)?ONLY$/i,
209
+ /^-?-?donly$/i
210
+ backup_the_data_directory_then_exit
211
+ # ===================================================================== #
212
+ # === rbackup --system-dir
213
+ # ===================================================================== #
214
+ when /^-?-?system(-| |_)?dir$/i,
215
+ /^-?-?system(-| |_)?directory$/i,
216
+ /^-?-?system$/i
217
+ backup_the_system_directory
218
+ do_not_perform_the_regular_backup_routine
219
+ # ===================================================================== #
220
+ # === rbackup --programs-dir
221
+ #
222
+ # This entry point can be used to backup /home/Programs/ specifically.
223
+ # ===================================================================== #
224
+ when /^-?-?programs(-| |_)?dir$/i,
225
+ /^-?-?programs$/i
226
+ backup_the_programs_directory
227
+ do_not_perform_the_regular_backup_routine
228
+ # ===================================================================== #
229
+ # === rbackup default
230
+ # ===================================================================== #
231
+ when 'default' # Default entry point is for /Mount/USB1 aka :usb1.
232
+ set_target_mountpoint(:usb1)
233
+ # ===================================================================== #
234
+ # === rbackup --mountpoints
235
+ # ===================================================================== #
236
+ when /^-?-?mountpoints/
237
+ show_available_mountpoints_then_exit
238
+ # ===================================================================== #
239
+ # === rbackup --logfile
240
+ # ===================================================================== #
241
+ when /^-?-?logfile\??$/i
242
+ show_the_logfile
243
+ do_not_perform_the_regular_backup_routine
244
+ # ===================================================================== #
245
+ # === rbackup --show-file-size-of-popular_directories
246
+ # === rbackup --overview
247
+ # ===================================================================== #
248
+ when /^-?-?show(-| |_)?file(-| |_)?size(-| |_)?of(-| |_)?popular(-| |_)?directories$/i,
249
+ /^-?-?overview$/i
250
+ use_this_array = [
251
+ return_the_songs_directory,
252
+ PROGRAMS_DIRECTORY,
253
+ VIDEO_DIRECTORY,
254
+ STUDIUM_DIRECTORY,
255
+ DATA_DIRECTORY,
256
+ SOURCE_DIRECTORY
257
+ ].map {|entry|
258
+ return_this_absolute_directory(entry)
259
+ }
260
+ use_this_array.each {|this_entry|
261
+ report_file_size_of(this_entry)
262
+ }
263
+ do_not_perform_the_regular_backup_routine
264
+ # ===================================================================== #
265
+ # === rbackup --use-this-as-target-for-backup=/opt/
266
+ # === rbackup --use-this-as-target=/opt/
267
+ # === rbackup --backup-to=/opt/
268
+ #
269
+ # This entry point allows the user to specify another target to
270
+ # be used from the commandline.
271
+ # ===================================================================== #
272
+ when /^-?-?backup(-| |_)?to=(.+)$/i,
273
+ /^-?-?use(-| |_)?this(-| |_)?as(-| |_)?target=(.+)$/i,
274
+ /^-?-?use(-| |_)?this(-| |_)?as(-| |_)?target(-| |_)?for(-| |_)?backup=(.+)$/i
275
+ _ = $2.to_s.dup
276
+ _ = $4.to_s.dup if $4
277
+ _ = $6.to_s.dup if $6
278
+ opnn; e 'The target device will be at '+sfancy(_)+'.'
279
+ set_target_device(_)
280
+ # ===================================================================== #
281
+ # === Use a shorter name for the backup-directory
282
+ #
283
+ # This entry point has been created to allow simpler backup onto
284
+ # NTFS devices. I ran into a problem with a too-long, and special
285
+ # name for a directory.
286
+ #
287
+ # Usage example:
288
+ #
289
+ # rbackup --use-shorter-name
290
+ # rbackup tousb1 --use-shorter-name
291
+ #
292
+ # ===================================================================== #
293
+ when /^-?-?use(-| |_)?shorter(-| |_)?name$/i,
294
+ /^-?-?windows$/i,
295
+ /^-?-?sane-symlink$/i
296
+ do_use_simplified_directory
297
+ # ===================================================================== #
298
+ # === rbackup --pwd
299
+ # ===================================================================== #
300
+ when /^-?-?pwd$/i
301
+ current_directory = (Dir.pwd+'/').squeeze('/')
302
+ set_target_mountpoint(current_directory)
303
+ # ===================================================================== #
304
+ # === rbackup --autogenerated
305
+ # ===================================================================== #
306
+ when /^-?-?autogen$/,
307
+ 'agen',
308
+ 'autog',
309
+ /^-?-?autogenerated$/i
310
+ determine_whether_the_target_harddisc_is_a_ntfs_system
311
+ try_to_backup_the_autogenerated_directory
312
+ do_not_perform_the_regular_backup_routine
313
+ else # else tag
314
+ # =================================================================== #
315
+ # === Backup an existing directory
316
+ #
317
+ # This entry point allows us to quickly backup an existing
318
+ # directory.
319
+ #
320
+ # Usage example:
321
+ #
322
+ # rbackup /home/x/data/rpg/
323
+ #
324
+ # =================================================================== #
325
+ if File.directory?(i)
326
+ i = File.absolute_path(i)
327
+ i << '/' unless i.end_with? '/'
328
+ new_target = @mountpoint.squeeze('/')
329
+ cpr(i, new_target)
330
+ all_done_message
331
+ do_not_perform_the_regular_backup_routine
332
+ # =================================================================== #
333
+ # === Backup individual .h files quickly
334
+ #
335
+ # This is a short circuit action here - we just backup an existing
336
+ # .h file quickly.
337
+ #
338
+ # Invocation example:
339
+ #
340
+ # rbackup /usr/include/xvid.h
341
+ #
342
+ # =================================================================== #
343
+ elsif File.exist?(i) and i.end_with?('.h')
344
+ base_directory = '/BACKUP/include/'
345
+ verbose_create_a_directory_at_this_position(base_directory)
346
+ target = "#{base_directory}#{File.basename(i)}"
347
+ opnn; e "Backing up towards `#{sfile(target)}` (a mere copy operation)."
348
+ copy_file(i, target)
349
+ do_not_perform_the_regular_backup_routine
350
+ else
351
+ if i and i.start_with?('--')
352
+ e "Option #{i} was not found. Exiting now."
353
+ exit
354
+ end
355
+ end
356
+ end
357
+ end
358
+ end
359
+
360
+ end; end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/utility_scripts/backup/run.rb'
6
+ # =========================================================================== #
7
+ module BackupParadise
8
+
9
+ class Backup < ::BackupParadise::Base # === BackupParadise::Backup
10
+
11
+ # ========================================================================= #
12
+ # === run (run tag)
13
+ # ========================================================================= #
14
+ def run
15
+ sanitize_the_commandline_arguments
16
+ menu
17
+ do_perform_the_backup_tasks if perform_the_regular_backup_routine?
18
+ end
19
+
20
+ end; end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/version/version.rb'
6
+ # =========================================================================== #
7
+ module BackupParadise
8
+
9
+ # ========================================================================= #
10
+ # === VERSION
11
+ # ========================================================================= #
12
+ VERSION = '1.2.37'
13
+
14
+ # ========================================================================= #
15
+ # === LAST_UPDATE
16
+ # ========================================================================= #
17
+ LAST_UPDATE = '21.05.2022'
18
+
19
+ end
@@ -0,0 +1 @@
1
+ This directory may contain code that we will use on windows.
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/windows/windows.rb'
6
+ # BackupParadise::Windows.backup_ingrid_directory
7
+ # =========================================================================== #
8
+ module BackupParadise
9
+
10
+ module Windows # === BackupParadise::Windows
11
+
12
+ require 'fileutils'
13
+ require 'backup_paradise/toplevel_methods/misc.rb'
14
+
15
+ alias e puts
16
+
17
+ # ========================================================================= #
18
+ # === BackupParadise::Windows.e
19
+ # ========================================================================= #
20
+ def self.e(i = '')
21
+ puts i
22
+ end
23
+
24
+ # ========================================================================= #
25
+ # === BackupParadise::Windows.return_the_current_time
26
+ # ========================================================================= #
27
+ def self.return_the_current_time
28
+ Time.now.strftime('%d.%m.%Y')
29
+ end
30
+
31
+ # ========================================================================= #
32
+ # === BackupParadise.do_use_fileutils_for_the_copy_action
33
+ # ========================================================================= #
34
+ def self.do_use_fileutils_for_the_copy_action
35
+ BackupParadise::CONFIG['use_system_cp'] = false
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === BackupParadise::Windows.backup_ingrid_directory
40
+ #
41
+ # This will try to backup c:\\ingrid\. It only works on windows really.
42
+ #
43
+ # The trailing '.' is necessary, so that the content of the directory
44
+ # is copied, rather than the directory itself and THEN its content.
45
+ # ========================================================================= #
46
+ def self.backup_ingrid_directory(
47
+ from = 'c://ingrid/.',
48
+ to = :infer_the_first_external_device
49
+ )
50
+ case to
51
+ # ======================================================================= #
52
+ # === :infer_the_first_external_device
53
+ #
54
+ # Here we will infer which external device is the first one.
55
+ # ======================================================================= #
56
+ when :infer_the_first_external_device
57
+ begin
58
+ require 'mountpoints'
59
+ rescue LoadError; end
60
+ if Object.const_defined? :Mountpoints
61
+ to = Mountpoints[]
62
+ else # else we will use a hardcoded approach.
63
+ e 'Assuming a hardcoded path at: e://'
64
+ to = "e://"
65
+ end
66
+ end
67
+ if to.is_a? Array
68
+ to = to.first
69
+ end
70
+ unless to.include? '_'
71
+ from = from.to_s.dup
72
+ from.chop! if from.end_with? '/'
73
+ if from.start_with?('c://') and BackupParadise.are_we_on_linux?
74
+ from[0,4] = ''
75
+ end
76
+ _ = to.to_s+
77
+ File.basename(from.to_s.delete('.'))+ # We remove '.' to avoid "ingrid/." stuff.
78
+ '_'+
79
+ return_the_current_time
80
+ _ = _.squeeze '/'
81
+ e 'Now creating the directory '+_+'.'
82
+ FileUtils.mkdir_p(_)
83
+ to = _
84
+ end
85
+ if File.directory?(from) and !from.end_with?('/', '.')
86
+ from = from.dup if from.frozen?
87
+ from << '/'
88
+ end
89
+ if File.directory?(to) and !to.end_with?('/')
90
+ to = to.dup if to.frozen?
91
+ to << '/'
92
+ end
93
+ do_use_fileutils_for_the_copy_action
94
+ BackupParadise.simple_backup(from, to)
95
+ end
96
+
97
+ end; end
98
+
99
+ if __FILE__ == $PROGRAM_NAME
100
+ BackupParadise::Windows.backup_ingrid_directory
101
+ end # backupingriddirectory
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This file may also mix non-objectified HTML tags.
6
+ # =========================================================================== #
7
+ # http://localhost/programming/ruby/src/cyberweb/examples/advanced/hybrid_experiment.cgi
8
+ # =========================================================================== #
9
+ require 'cyberweb/requires/require_objectified_html_tags_files.rb'
10
+ require 'cyberweb/requires/require_the_toplevel_methods_files.rb'
11
+ require 'cyberweb/requires/require_the_html_template.rb'
12
+ require 'cyberweb/web_images/map_symbol_to_image_location.rb'
13
+ require 'cyberweb/javascript/drag_and_drop.rb'
14
+ require 'cyberweb/toplevel_methods/jquery.rb'
15
+ require 'backup_paradise'
16
+
17
+ alias ee print
18
+
19
+ Cyberweb.require_objectified_html_tags_files
20
+ Cyberweb.require_toplevel_methods_files
21
+
22
+ include Cyberweb::Objectified::HtmlTags
23
+ include Cyberweb
24
+
25
+ ee "Content-type: text/html\n\n"
26
+ ee '<html><head>'
27
+
28
+ Title.report('Backup-related actions')
29
+ ee '<style>'
30
+ ee Cyberweb.return_content_of_all_the_CSS_files
31
+ ee '</style>'
32
+ ee Cyberweb.return_jquery_string
33
+ ee '</head>'
34
+ ee '<body class="mar4px">'
35
+
36
+ ee Cyberweb.params?
37
+ # =========================================================================== #
38
+ # Hello world div:
39
+ # =========================================================================== #
40
+ ee '<form method="POST" id="backup_form" name="backup_form" class="FS1_5em mars1em mart1em" action="">'
41
+
42
+ ee 'Backup c:\ingrid\\<br><br>'
43
+ _ = submit_button
44
+ _.name = 'do_backup_for_ingrid'
45
+ _.value = 'Do backup c:\ingrid\\'
46
+ _.bblack2
47
+ _.css_class 'pad8px mar4px mars2em FS1_3em'
48
+ _.style 'border: 3px dotted tomato'
49
+ _.report
50
+ # ee '<img src="../../../../../../../data/images/'+Cyberweb.get_webimage(:backup_image)+'">'
51
+ ee '<input name="do_backup_for_ingrid" type="image" src="../../../../../../../data/images/'+
52
+ Cyberweb.get_webimage(:backup_image)+'" border="0" alt="Submit"/>'
53
+
54
+ # <form class="spacer" action="" method="post">
55
+ # <input class="submit" type="submit" value="Submit" />
56
+ # </form>
57
+
58
+
59
+
60
+ ee '</form>'
61
+
62
+ ee '</body>'
63
+ ee '</html>'