backup_paradise 1.3.1

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 (50) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +408 -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 +368 -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 +502 -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 +220 -0
  19. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/create.rb +70 -0
  20. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/misc.rb +33 -0
  21. data/lib/backup_paradise/gui/gtk3/simple_backup_widget/simple_backup_widget.rb +160 -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 +587 -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 +86 -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 +188 -0
  41. data/lib/backup_paradise/toplevel_methods/opnn.rb +27 -0
  42. data/lib/backup_paradise/utility_scripts/backup/backup.rb +1901 -0
  43. data/lib/backup_paradise/version/version.rb +19 -0
  44. data/lib/backup_paradise/windows/README.md +1 -0
  45. data/lib/backup_paradise/windows/windows.rb +101 -0
  46. data/lib/backup_paradise/www/backup.cgi +63 -0
  47. data/lib/backup_paradise/yaml/config.yml +82 -0
  48. data/lib/backup_paradise.rb +5 -0
  49. data/test/testing_toplevel_functionality.rb +11 -0
  50. metadata +194 -0
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/toplevel_methods/misc.rb'
6
+ # =========================================================================== #
7
+ module BackupParadise
8
+
9
+ require 'backup_paradise/toplevel_methods/files_and_directories.rb'
10
+ require 'backup_paradise/toplevel_methods/mountpoint.rb'
11
+ require 'backup_paradise/tab/tab.rb'
12
+
13
+ require 'backup_paradise/colours/colours.rb'
14
+ # ========================================================================= #
15
+ # === report_current_dir
16
+ #
17
+ # This method will tell us about the current directory.
18
+ # ========================================================================= #
19
+ def self.report_current_dir
20
+ e "Current location is: #{sdir(Dir.pwd)}"
21
+ end; self.instance_eval { alias report_pwd report_current_dir } # === BackupParadise.report_pwd
22
+ self.instance_eval { alias report_current_directory report_current_dir } # === BackupParadise.report_current_directory
23
+
24
+ # ========================================================================= #
25
+ # === debug (debug tag)
26
+ #
27
+ # This is just "quick" debug output.
28
+ # ========================================================================= #
29
+ def debug
30
+ e
31
+ e ' Data directory: '+sfancy(data_directory?)
32
+ e " Main mount point: #{sfancy(mount_point?.to_s)}"
33
+ e
34
+ end
35
+
36
+ # ========================================================================= #
37
+ # === BackupParadise.tab_title
38
+ # ========================================================================= #
39
+ def self.tab_title(
40
+ use_this_title = ''
41
+ )
42
+ BackupParadise::Tab.rename_tab(:default, use_this_title)
43
+ end
44
+
45
+ # ========================================================================= #
46
+ # === BackupParadise.are_we_on_windows?
47
+ #
48
+ # Query whether the underlying operating system is windows or whether
49
+ # it is not.
50
+ # ========================================================================= #
51
+ def self.are_we_on_windows?
52
+ Gem.win_platform?
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === BackupParadise.are_we_on_linux?
57
+ # ========================================================================= #
58
+ def self.are_we_on_linux?
59
+ RbConfig::CONFIG['host_os'].include? 'linux'
60
+ end
61
+
62
+ # ========================================================================= #
63
+ # === BackupParadise.simple_backup
64
+ #
65
+ # Use this toplevel-method to backup something individually. This will
66
+ # deliberately NOT make use of class BackupParadise::Backup, to keep
67
+ # things as simple as possible in this regard.
68
+ #
69
+ # To invoke this method, try any of the following:
70
+ #
71
+ # BackupParadise.simple_backup(:audio, '/Mount/HDD1/')
72
+ # BackupParadise.simple_backup(:audio_dir, '/Mount/HDD1/')
73
+ # BackupParadise.simple_backup(:system_dir, '/Mount/HDD1/')
74
+ # BackupParadise.simple_backup(:audio, :usb1)
75
+ #
76
+ # ========================================================================= #
77
+ def self.simple_backup(
78
+ this_directory_or_file = '/home/x/songs/',
79
+ target_location = '/Mount/USB1/', # '/Mount/HDD1/',
80
+ be_verbose = true
81
+ )
82
+ if this_directory_or_file.is_a? Array
83
+ this_directory_or_file.each {|entry|
84
+ Backup.simple_backup(entry, target_location, be_verbose)
85
+ }
86
+ else
87
+ # ===================================================================== #
88
+ # First, handle some special Symbols. This must come before rds().
89
+ # ===================================================================== #
90
+ case this_directory_or_file
91
+ # ===================================================================== #
92
+ # === :audio
93
+ # ===================================================================== #
94
+ when :audio,
95
+ :audio_dir, :songs, :songs_dir, :default,
96
+ :audio_directory
97
+ this_directory_or_file = DIRECTORY_CONTAINING_ALL_SONGS
98
+ # ===================================================================== #
99
+ # === :pkg_dir
100
+ # ===================================================================== #
101
+ when :pkg_dir
102
+ this_directory_or_file = '/Depot/Packages/'
103
+ # ===================================================================== #
104
+ # === :system_dir
105
+ # ===================================================================== #
106
+ when :system_dir, :sys_dir
107
+ this_directory_or_file = '/System/'
108
+ end
109
+ this_directory_or_file = rds(this_directory_or_file)
110
+ if target_location.is_a? Symbol
111
+ # =================================================================== #
112
+ # Symbols are treated in a special manner.
113
+ # =================================================================== #
114
+ if BackupParadise.is_this_a_shortcut?(target_location.to_s)
115
+ target_location =
116
+ BackupParadise.return_the_assumed_mountpoint_from_this_input(target_location.to_s)
117
+ end
118
+ end
119
+ this_directory_or_file = this_directory_or_file.dup if this_directory_or_file.frozen?
120
+ if this_directory_or_file.end_with?('/.')
121
+ # =================================================================== #
122
+ # The next line was added because it was noticed that windows, for
123
+ # some odd reason, may append a '.' character to a directory.
124
+ # =================================================================== #
125
+ this_directory_or_file.chop! # Remove the last char, which is '.' in this case.
126
+ end
127
+ target_location = target_location.to_s
128
+ e "Now backing up directory `#{sdir(this_directory_or_file)}"\
129
+ "` to `#{sdir(target_location)}`."
130
+ cpr(
131
+ this_directory_or_file,
132
+ target_location,
133
+ be_verbose
134
+ )
135
+ tab_title 'Backing up now ...' unless are_we_on_windows?
136
+ end
137
+ end
138
+
139
+ # ========================================================================= #
140
+ # === BackupParadise.rds
141
+ # ========================================================================= #
142
+ def self.rds(i)
143
+ i.to_s.squeeze '/'
144
+ end
145
+
146
+ # ========================================================================= #
147
+ # === BackupParadise.is_on_roebe?
148
+ # ========================================================================= #
149
+ def self.is_on_roebe?
150
+ ENV['IS_ROEBE'].to_s == '1'
151
+ end
152
+
153
+ end
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/toplevel_methods/mountpoint.rb'
6
+ # BackupParadise.target_mountpoint=
7
+ # =========================================================================== #
8
+ module BackupParadise
9
+
10
+ require 'backup_paradise/toplevel_methods/config.rb'
11
+
12
+ # ========================================================================= #
13
+ # === @target_mountpoint
14
+ # ========================================================================= #
15
+ @target_mountpoint = '/Mount/USB1/'
16
+
17
+ # ========================================================================= #
18
+ # === BackupParadise.is_this_a_shortcut?
19
+ # ========================================================================= #
20
+ def self.is_this_a_shortcut?(i)
21
+ returned_value = return_the_assumed_mountpoint_from_this_input(i)
22
+ # ======================================================================= #
23
+ # It is a shortcut when we have replaced it.
24
+ # ======================================================================= #
25
+ !(returned_value == i)
26
+ end
27
+
28
+ # ========================================================================= #
29
+ # === BackupParadise.return_the_assumed_mountpoint_from_this_input
30
+ #
31
+ # This method will replace e. g. "usb1" with ENV['USB1'] or the
32
+ # config-setting. The config setting takes priority over the ENV
33
+ # setting.
34
+ # ========================================================================= #
35
+ def self.return_the_assumed_mountpoint_from_this_input(i)
36
+ case i # case tag
37
+ # ======================================================================= #
38
+ # === :pwd
39
+ # ======================================================================= #
40
+ when 'pwd',
41
+ :pwd,
42
+ :""
43
+ i = Dir.pwd
44
+ # ======================================================================= #
45
+ # === :usb1
46
+ #
47
+ # Note that nil also defaults to :usb1.
48
+ # ======================================================================= #
49
+ when :usb1,
50
+ :default,
51
+ 'usb1',
52
+ 'usb',
53
+ 'tousb',
54
+ /^-?-?to(-|_)?usb1/,
55
+ '1',
56
+ /^-?-?usb1/,
57
+ nil
58
+ if CONFIG and CONFIG.has_key?('usb1')
59
+ i = CONFIG['usb1'].to_s
60
+ else
61
+ i = ENV['USB1']
62
+ end
63
+ # ======================================================================= #
64
+ # === :usb2
65
+ # ======================================================================= #
66
+ when :usb2,
67
+ 'usb2',
68
+ /^-?-?to(-|_)?usb2/,
69
+ '2',
70
+ /^-?-?usb2/
71
+ if CONFIG and CONFIG.has_key?('usb2')
72
+ i = CONFIG['usb2'].to_s
73
+ else
74
+ i = ENV['USB2']
75
+ end
76
+ # ======================================================================= #
77
+ # === :usb3
78
+ # ======================================================================= #
79
+ when '3',
80
+ /^-?-?usb3/,
81
+ /^-?-?to(-|_)?usb3/,
82
+ :usb3
83
+ if CONFIG and CONFIG.has_key?('usb3')
84
+ i = CONFIG['usb3'].to_s
85
+ else
86
+ i = ENV['USB3']
87
+ end
88
+ # ======================================================================= #
89
+ # === :usb4
90
+ # ======================================================================= #
91
+ when '4',
92
+ :usb4,
93
+ /^-?-?usb4/,
94
+ /^-?-?to(-|_)?usb4/
95
+ if CONFIG and CONFIG.has_key?('usb4')
96
+ i = CONFIG['usb4'].to_s
97
+ else
98
+ i = ENV['USB4']
99
+ end
100
+ # ======================================================================= #
101
+ # === :usb5
102
+ # ======================================================================= #
103
+ when 'usb5',
104
+ /^-?-?usb5/,
105
+ /^-?-?to(-|_)?usb5/,
106
+ '5',
107
+ :usb5
108
+ if CONFIG and CONFIG.has_key?('usb5')
109
+ i = CONFIG['usb5'].to_s
110
+ else
111
+ i = ENV['USB5']
112
+ end
113
+ # ======================================================================= #
114
+ # === :chroot
115
+ # ======================================================================= #
116
+ when :chroot,
117
+ 'chroot'
118
+ i = ENV['CHROOT_TARGET']
119
+ if i.nil?
120
+ i = '/Depot/Chroot/' # Hardcoded target in this case.
121
+ end
122
+ # ======================================================================= #
123
+ # === :to_hdd
124
+ # ======================================================================= #
125
+ when 'tohd',
126
+ 'hdd1',
127
+ :to_hdd,
128
+ /^-?-?to(-|_)?hdd1?/i
129
+ i = BackupParadise.config?['hdd1'] # ENV['FESTPLATTE1'].to_s.dup
130
+ # ======================================================================= #
131
+ # === :to_hdd2
132
+ # ======================================================================= #
133
+ when 'hdd2',
134
+ :to_hdd2,
135
+ /^-?-?to(-|_)?hdd2/i
136
+ i = BackupParadise.config?['hdd2'] # ENV['FESTPLATTE1'].to_s.dup
137
+ end
138
+ # ======================================================================= #
139
+ # The input could still be a Symbol, so the next line exists to protect
140
+ # us against this.
141
+ # ======================================================================= #
142
+ i = i.to_s unless i.is_a?(String)
143
+ if i and File.directory?(i) and !i.end_with?('/')
144
+ i = i.dup if i.frozen?
145
+ i << '/' # Ensure a trailing '/'.
146
+ end
147
+ return i # Always return it.
148
+ end
149
+
150
+ # ========================================================================= #
151
+ # === BackupParadise.target_mountpoint= (target tag)
152
+ #
153
+ # Use this method to determine the main target mountpoint that is
154
+ # to be used. This must be the base directory, not a subdirectory.
155
+ #
156
+ # An example for this, on my home system, would be /Mount/USB1/.
157
+ # ========================================================================= #
158
+ def self.target_mountpoint=(i = :usb1)
159
+ if i.is_a? String
160
+ i = i.dup if i.frozen?
161
+ i.squeeze!('/')
162
+ end
163
+ if BackupParadise.is_this_a_shortcut?(i)
164
+ i = return_the_assumed_mountpoint_from_this_input(i)
165
+ end
166
+ # ======================================================================= #
167
+ # Ensure that a trailing '/' is used.
168
+ # ======================================================================= #
169
+ unless i.end_with? '/'
170
+ i = i.dup if i.frozen?
171
+ i << '/'
172
+ end
173
+ @target_mountpoint = i
174
+ end; self.instance_eval { alias set_mounted_path target_mountpoint= } # === BackupParadise.set_mounted_path
175
+ self.instance_eval { alias set_target_device target_mountpoint= } # === BackupParadise.set_target_device
176
+ self.instance_eval { alias set_backup_to_this_directory target_mountpoint= } # === BackupParadise.set_backup_to_this_directory
177
+ self.instance_eval { alias set_target target_mountpoint= } # === BackupParadise.set_target
178
+ self.instance_eval { alias set_target_mountpoint target_mountpoint= } # === BackupParadise.set_target_mountpoint
179
+ self.instance_eval { alias set_main_target target_mountpoint= } # === BackupParadise.set_main_target
180
+
181
+ # ========================================================================= #
182
+ # === BackupParadise.target_mountpoint?
183
+ # ========================================================================= #
184
+ def self.target_mountpoint?
185
+ @target_mountpoint
186
+ end
187
+
188
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'backup_paradise/toplevel_methods/opnn.rb'
6
+ # =========================================================================== #
7
+ module BackupParadise
8
+
9
+ begin
10
+ require 'opn'
11
+ rescue LoadError; end
12
+
13
+ # ========================================================================= #
14
+ # === BackupParadise.opnn
15
+ # ========================================================================= #
16
+ def self.opnn(
17
+ i = {
18
+ namespace: NAMESPACE
19
+ }
20
+ )
21
+ if i.is_a? String
22
+ i = { namespace: i }
23
+ end
24
+ Opn.opn(i)
25
+ end; self.instance_eval { alias opn opnn } # === BackupParadise.opnn
26
+
27
+ end