backup_paradise 1.2.13
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.
- checksums.yaml +7 -0
- data/README.md +231 -0
- data/backup_paradise.gemspec +51 -0
- data/bin/backup_paradise +7 -0
- data/doc/README.gen +214 -0
- data/doc/TODO.md +221 -0
- data/lib/backup_paradise.rb +5 -0
- data/lib/backup_paradise/advanced_backup/advanced_backup.rb +53 -0
- data/lib/backup_paradise/advanced_backup/audio.rb +124 -0
- data/lib/backup_paradise/advanced_backup/constants.rb +34 -0
- data/lib/backup_paradise/advanced_backup/data_directory.rb +50 -0
- data/lib/backup_paradise/advanced_backup/do_perform_the_backup_tasks.rb +95 -0
- data/lib/backup_paradise/advanced_backup/initialize.rb +38 -0
- data/lib/backup_paradise/advanced_backup/menu.rb +280 -0
- data/lib/backup_paradise/advanced_backup/misc.rb +836 -0
- data/lib/backup_paradise/advanced_backup/reset.rb +56 -0
- data/lib/backup_paradise/advanced_backup/run.rb +26 -0
- data/lib/backup_paradise/advanced_backup/system_directory.rb +35 -0
- data/lib/backup_paradise/base/base.rb +440 -0
- data/lib/backup_paradise/base/colours.rb +123 -0
- data/lib/backup_paradise/base/constants.rb +16 -0
- data/lib/backup_paradise/constants/constants.rb +192 -0
- data/lib/backup_paradise/gui/gtk2/backup.rb +345 -0
- data/lib/backup_paradise/gui/gtk3/backup.rb +383 -0
- data/lib/backup_paradise/project/project_base_directory.rb +22 -0
- data/lib/backup_paradise/requires/require_the_backup_paradise_project.rb +14 -0
- data/lib/backup_paradise/tab/tab.rb +84 -0
- data/lib/backup_paradise/toplevel_methods/cliner.rb +16 -0
- data/lib/backup_paradise/toplevel_methods/colours.rb +80 -0
- data/lib/backup_paradise/toplevel_methods/e.rb +16 -0
- data/lib/backup_paradise/toplevel_methods/help.rb +88 -0
- data/lib/backup_paradise/toplevel_methods/misc.rb +343 -0
- data/lib/backup_paradise/toplevel_methods/mountpoint.rb +80 -0
- data/lib/backup_paradise/toplevel_methods/opnn.rb +21 -0
- data/lib/backup_paradise/version/version.rb +19 -0
- data/lib/backup_paradise/yaml/config.yml +22 -0
- metadata +178 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/toplevel_methods/cliner.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module BackupParadise
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === BackupParadise.cliner
|
11
|
+
# ========================================================================= #
|
12
|
+
def self.cliner
|
13
|
+
puts '=' * 80
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/toplevel_methods/colours.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module BackupParadise
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'colours'
|
11
|
+
rescue LoadError; end
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === use_colours
|
15
|
+
# ========================================================================= #
|
16
|
+
@use_colours = true
|
17
|
+
|
18
|
+
# ========================================================================= #
|
19
|
+
# === BackupParadise.use_colours?
|
20
|
+
# ========================================================================= #
|
21
|
+
def self.use_colours?
|
22
|
+
@use_colours
|
23
|
+
end
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === BackupParadise.use_colours=
|
27
|
+
# ========================================================================= #
|
28
|
+
def self.use_colours=(i)
|
29
|
+
@use_colours = i
|
30
|
+
end
|
31
|
+
|
32
|
+
# ========================================================================= #
|
33
|
+
# === BackupParadise.sfancy
|
34
|
+
# ========================================================================= #
|
35
|
+
def self.sfancy(i)
|
36
|
+
return Colours.sfancy(i) if @use_colours
|
37
|
+
i
|
38
|
+
end
|
39
|
+
|
40
|
+
# ========================================================================= #
|
41
|
+
# === BackupParadise.sdir
|
42
|
+
# ========================================================================= #
|
43
|
+
def self.sdir(i)
|
44
|
+
return Colours.sdir(i) if @use_colours
|
45
|
+
i
|
46
|
+
end
|
47
|
+
|
48
|
+
# ========================================================================= #
|
49
|
+
# === BackupParadise.sfile
|
50
|
+
# ========================================================================= #
|
51
|
+
def self.sfile(i)
|
52
|
+
return Colours.sfile(i) if @use_colours
|
53
|
+
i
|
54
|
+
end
|
55
|
+
|
56
|
+
# ========================================================================= #
|
57
|
+
# === BackupParadise.simp
|
58
|
+
# ========================================================================= #
|
59
|
+
def self.simp(i)
|
60
|
+
return Colours.simp(i) if @use_colours
|
61
|
+
i
|
62
|
+
end
|
63
|
+
|
64
|
+
# ========================================================================= #
|
65
|
+
# === BackupParadise.royalblue
|
66
|
+
# ========================================================================= #
|
67
|
+
def self.royalblue(i)
|
68
|
+
return Colours.royalblue(i) if @use_colours
|
69
|
+
i
|
70
|
+
end
|
71
|
+
|
72
|
+
# ========================================================================= #
|
73
|
+
# === BackupParadise.tomato
|
74
|
+
# ========================================================================= #
|
75
|
+
def self.tomato(i)
|
76
|
+
return Colours.tomato(i) if @use_colours
|
77
|
+
i
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/toplevel_methods/e.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module BackupParadise
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === BackupParadise.e
|
11
|
+
# ========================================================================= #
|
12
|
+
def self.e(i = '')
|
13
|
+
puts i
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/toplevel_methods/help.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'backup_paradise/toplevel_methods/cliner.rb'
|
8
|
+
require 'backup_paradise/toplevel_methods/colours.rb'
|
9
|
+
|
10
|
+
module BackupParadise
|
11
|
+
|
12
|
+
# ========================================================================= #
|
13
|
+
# === BackupParadise.show_help (help tag)
|
14
|
+
#
|
15
|
+
# Here we register all help-related methods.
|
16
|
+
#
|
17
|
+
# Two hints are registered, "tohdd", and "no-gtk".
|
18
|
+
# To use this, do: Help.show_help
|
19
|
+
#
|
20
|
+
# Or, from the commandline:
|
21
|
+
#
|
22
|
+
# rbackup --help
|
23
|
+
#
|
24
|
+
# ========================================================================= #
|
25
|
+
def self.show_help
|
26
|
+
e
|
27
|
+
cliner
|
28
|
+
e ' - Please note that you can use any order for the arguments.'
|
29
|
+
e
|
30
|
+
e 'Documented help options are:'
|
31
|
+
e
|
32
|
+
e ' rbackup --programs-dir # Back up the /Programs/ directory quickly'
|
33
|
+
e ' rbackup --backup-to=/PATH # Back up into the PATH directory.'
|
34
|
+
e
|
35
|
+
e 'The following options are NOT yet tested!'
|
36
|
+
e
|
37
|
+
e " - Pass #{sfancy('tohdd')} to backup to the hdd (usually "\
|
38
|
+
"this is the second harddisc)."
|
39
|
+
e
|
40
|
+
e ' - Pass '+sfancy('tousb ')+'to backup to the (first) usb media.'
|
41
|
+
e ' (Aliases exist, such as '+sfancy('usb1')+sfancy(' usb2')+
|
42
|
+
sfancy(' usb3')+' and so forth)'
|
43
|
+
e
|
44
|
+
e ' - Pass '+sfancy('data_only ')+'to backup only the '+
|
45
|
+
sdir(HOME_DIRECTORY_OF_THE_USER_X+'DATA/')+' directory.'
|
46
|
+
e
|
47
|
+
e ' - In general you can backup individual dir as wells.'
|
48
|
+
e
|
49
|
+
e ' Examples for this:'
|
50
|
+
e
|
51
|
+
e sfancy(' rbackup audio')
|
52
|
+
e sfancy(' rbackup data')
|
53
|
+
e
|
54
|
+
e ' - You can also chain together commands.'
|
55
|
+
e ' Example for chaining together commands:'
|
56
|
+
e sfancy(' rbackup data_only usb1')
|
57
|
+
e sfancy(' rbackup audio_only usb1')
|
58
|
+
e
|
59
|
+
e ' - You can backup the /Programs directory.'
|
60
|
+
e ' Issue the following command here:'
|
61
|
+
e sfancy(' rbackup usb1 programs')
|
62
|
+
e sfancy(' rbackup usb1 /Programs')
|
63
|
+
e
|
64
|
+
e ' - If you do the following.'
|
65
|
+
e ' Examples:'
|
66
|
+
e sfancy(' rbackup no-mount1')
|
67
|
+
e ' Then we wont try to (re)mount the device again.'
|
68
|
+
e
|
69
|
+
e 'If you want to show the time it took to backup the last some'
|
70
|
+
e 'backup-jobs, use this commandline flag:'
|
71
|
+
e
|
72
|
+
e sfancy(' rbackup --logfile')
|
73
|
+
e
|
74
|
+
e 'To simply backup into the current working '\
|
75
|
+
'directory (cwd, pwd)'
|
76
|
+
e 'use:'
|
77
|
+
e
|
78
|
+
e sfancy(' rbackup --pwd')
|
79
|
+
e
|
80
|
+
e 'To use the GTK3 GUI, you could try:'
|
81
|
+
e
|
82
|
+
e sfancy(' rbackup --gui')
|
83
|
+
e
|
84
|
+
cliner
|
85
|
+
e
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,343 @@
|
|
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
|
+
require 'fileutils'
|
8
|
+
require 'backup_paradise/constants/constants.rb'
|
9
|
+
require 'backup_paradise/project/project_base_directory.rb'
|
10
|
+
require 'backup_paradise/toplevel_methods/colours.rb'
|
11
|
+
require 'backup_paradise/toplevel_methods/e.rb'
|
12
|
+
require 'backup_paradise/toplevel_methods/opnn.rb'
|
13
|
+
require 'backup_paradise/version/version.rb'
|
14
|
+
|
15
|
+
module BackupParadise
|
16
|
+
|
17
|
+
_ = "#{BackupParadise::PROJECT_BASE_DIRECTORY}yaml/config.yml" # bl $RUBY_BACKUP/YAML/config.yml
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === CONFIG
|
21
|
+
#
|
22
|
+
# Keep track of the configuration of the backup-paradise project.
|
23
|
+
# ========================================================================= #
|
24
|
+
if File.exist? _
|
25
|
+
CONFIG = YAML.load_file(_) # This will be a Hash.
|
26
|
+
else
|
27
|
+
CONFIG = {}
|
28
|
+
end
|
29
|
+
|
30
|
+
# ========================================================================= #
|
31
|
+
# === BackupParadise.remove
|
32
|
+
#
|
33
|
+
# Easier wrapper when we need to remove something, be it a directory
|
34
|
+
# or a file or a symlink.
|
35
|
+
# ========================================================================= #
|
36
|
+
def self.remove(i)
|
37
|
+
if i.is_a? Array
|
38
|
+
i.each {|entry| remove(entry) }
|
39
|
+
else
|
40
|
+
i = rds(i)
|
41
|
+
_ = i.dup
|
42
|
+
if File.directory? i
|
43
|
+
_ = sdir(i)
|
44
|
+
elsif File.file?(i)
|
45
|
+
_ = sfile(i)
|
46
|
+
else # else it will just be fancy.
|
47
|
+
_ = sfancy(i)
|
48
|
+
end
|
49
|
+
e "Trying to remove `#{_}` next."
|
50
|
+
if File.directory?(i)
|
51
|
+
remove_directory(i)
|
52
|
+
elsif File.file?(i)
|
53
|
+
remove_this_file(i) # Defined in this file here.
|
54
|
+
else
|
55
|
+
e 'Not found the action: "'+sfancy(i)+'"'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# ========================================================================= #
|
61
|
+
# === report_current_dir
|
62
|
+
#
|
63
|
+
# This method will tell us about the current directory.
|
64
|
+
# ========================================================================= #
|
65
|
+
def self.report_current_dir
|
66
|
+
e "Current location is: #{sdir(Dir.pwd)}"
|
67
|
+
end; self.instance_eval { alias report_pwd report_current_dir } # === BackupParadise.report_pwd
|
68
|
+
self.instance_eval { alias report_current_directory report_current_dir } # === BackupParadise.report_current_directory
|
69
|
+
|
70
|
+
# ========================================================================= #
|
71
|
+
# === BackupParadise.remove_this_file
|
72
|
+
#
|
73
|
+
# Use this method to remove a file.
|
74
|
+
# ========================================================================= #
|
75
|
+
def self.remove_this_file(this_file)
|
76
|
+
e "Removing the file `#{sfile(this_file)}` now."
|
77
|
+
FileUtils.rm(this_file)
|
78
|
+
end
|
79
|
+
|
80
|
+
# ========================================================================= #
|
81
|
+
# === BackupParadise.size?
|
82
|
+
#
|
83
|
+
# Gives you the size of the given subdirectory.
|
84
|
+
#
|
85
|
+
# Usage Example:
|
86
|
+
#
|
87
|
+
# BackupParadise.size?(ENV['J']) # => 1_396_436_232
|
88
|
+
# BackupParadise.size?(BackupParadise::AUDIO_DIR) # => 1_396_436_232
|
89
|
+
#
|
90
|
+
# ========================================================================= #
|
91
|
+
def self.size?(subdir_part)
|
92
|
+
size = 0 # Default.
|
93
|
+
begin
|
94
|
+
subdir_part = "#{subdir_part}/**/*"
|
95
|
+
results = Dir[subdir_part]
|
96
|
+
size = results.inject(0) { |sum, entry|
|
97
|
+
result = 0
|
98
|
+
result = sum + File.size(entry) if File.exist? entry
|
99
|
+
result
|
100
|
+
}
|
101
|
+
rescue; end # Make it failsave.
|
102
|
+
return size.to_s
|
103
|
+
end
|
104
|
+
|
105
|
+
# ========================================================================= #
|
106
|
+
# === BackupParadise.size_in_gigabytes?
|
107
|
+
#
|
108
|
+
# This method will return the size of the target directory in gigabytes.
|
109
|
+
# ========================================================================= #
|
110
|
+
def self.size_in_gigabytes?(i = BackupParadise::AUDIO_DIR)
|
111
|
+
(
|
112
|
+
BackupParadise.size?(i).to_f / 1024.0 / 1024.0 / 1000.0
|
113
|
+
).round(1).to_f
|
114
|
+
end
|
115
|
+
|
116
|
+
# ========================================================================= #
|
117
|
+
# === BackupParadise.rds
|
118
|
+
# ========================================================================= #
|
119
|
+
def self.rds(i)
|
120
|
+
i.squeeze '/'
|
121
|
+
end
|
122
|
+
|
123
|
+
# ========================================================================= #
|
124
|
+
# === BackupParadise.copy_file
|
125
|
+
#
|
126
|
+
# Copy a file with this method.
|
127
|
+
# ========================================================================= #
|
128
|
+
def self.copy_file(file, where_to)
|
129
|
+
begin
|
130
|
+
FileUtils.cp(file, where_to)
|
131
|
+
rescue Errno::ENOSPC # Not enough space on target device.
|
132
|
+
opnn; e 'We must exit now - there is not enough space left on the '
|
133
|
+
opnn; e 'target hdd.'
|
134
|
+
rescue Errno::EINVAL # Invalid argument @ rb_sysopen
|
135
|
+
opnn; e 'The file can not be copied, possibly because it '\
|
136
|
+
'contains a german umlaut.'
|
137
|
+
opnn; e 'We will however continue nonetheless.'
|
138
|
+
rescue Errno::EISDIR
|
139
|
+
opnn; e 'We currently do not copy directories, only files.'
|
140
|
+
rescue Errno::EILSEQ => error
|
141
|
+
opnn; e "It seems that we have an invalid or incomplete multibyte "\
|
142
|
+
"or wide-character at file `#{sfile(file.to_s)}`."
|
143
|
+
opnn; e 'We thus can not copy this file.'
|
144
|
+
pp error
|
145
|
+
rescue Exception => error # In lucky days, we will never reach this here.
|
146
|
+
pp error
|
147
|
+
opnn; e 'The above error should be intercepted - please add it,'
|
148
|
+
opnn; e 'then press the ENTER key in order to continue.'
|
149
|
+
$stdin.gets.chomp # We will remove this line here eventually.
|
150
|
+
end
|
151
|
+
end; self.instance_eval { alias copy_this_file copy_file } # === BackupParadise.copy_this_file
|
152
|
+
|
153
|
+
# ========================================================================= #
|
154
|
+
# === BackupParadise.copy_recursively
|
155
|
+
#
|
156
|
+
# Copy the source to the target in a recursive manner.
|
157
|
+
#
|
158
|
+
# The third argument to this method, `be_verbose`, will feedback
|
159
|
+
# to the user if it is set to true. Otherwise, we will just copy
|
160
|
+
# silently.
|
161
|
+
# ========================================================================= #
|
162
|
+
def self.copy_recursively(
|
163
|
+
source,
|
164
|
+
target,
|
165
|
+
be_verbose = :be_verbose
|
166
|
+
)
|
167
|
+
case be_verbose
|
168
|
+
when :be_verbose
|
169
|
+
be_verbose = true
|
170
|
+
end
|
171
|
+
hash_to_use = {
|
172
|
+
verbose: be_verbose
|
173
|
+
}
|
174
|
+
source = source.dup if source.frozen?
|
175
|
+
if source.include? '*'
|
176
|
+
require 'convert_global_env'
|
177
|
+
source = ConvertGlobalEnv[source].dup
|
178
|
+
elsif Dir.exist?(source)
|
179
|
+
source << '*'
|
180
|
+
end
|
181
|
+
source = rds(source)
|
182
|
+
target = rds(target)
|
183
|
+
begin
|
184
|
+
case BackupParadise.use_system_cp?
|
185
|
+
# ===================================================================== #
|
186
|
+
# === true
|
187
|
+
#
|
188
|
+
# In that case we will use system cp.
|
189
|
+
# ===================================================================== #
|
190
|
+
when true
|
191
|
+
system("cp -Rv #{source} #{target}")
|
192
|
+
# ===================================================================== #
|
193
|
+
# === false
|
194
|
+
# ===================================================================== #
|
195
|
+
when false, nil, '', 'default' # In this event we will use FileUtils module.
|
196
|
+
extend FileUtils::Verbose if be_verbose
|
197
|
+
# source[-1,1] = '' if source[-1,1] == '*'
|
198
|
+
FileUtils.cp_r(
|
199
|
+
source, target, hash_to_use
|
200
|
+
)
|
201
|
+
end
|
202
|
+
rescue Exception => error
|
203
|
+
opnn; e 'An error occurred in method cpr(): '+error.class.to_s
|
204
|
+
pp error
|
205
|
+
end
|
206
|
+
|
207
|
+
end; self.instance_eval { alias cpr copy_recursively } # === BackupParadise.cpr
|
208
|
+
|
209
|
+
# ========================================================================= #
|
210
|
+
# === BackupParadise.remove_directory
|
211
|
+
# ========================================================================= #
|
212
|
+
def self.remove_directory(i)
|
213
|
+
i = rds(i)
|
214
|
+
unless i == '/' # Tiny "safeguard".
|
215
|
+
FileUtils.rm_rf(i) if File.directory?(i)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# ========================================================================= #
|
220
|
+
# === BackupParadise.change_directory (cd tag, chdir tag)
|
221
|
+
#
|
222
|
+
# This should no longer be required.
|
223
|
+
# ========================================================================= #
|
224
|
+
def self.change_directory(i)
|
225
|
+
Dir.chdir(i) if File.directory?(i)
|
226
|
+
end; self.instance_eval { alias cd change_directory } # === BackupParadise.cd
|
227
|
+
|
228
|
+
# ========================================================================= #
|
229
|
+
# === BackupParadise.create_directory
|
230
|
+
#
|
231
|
+
# Dir.mkdir would be an alternative. We require DEFAULT_MODE to be set
|
232
|
+
# before we can use this method here - hence why we require the file
|
233
|
+
# constants.rb.
|
234
|
+
# ========================================================================= #
|
235
|
+
def self.create_directory(
|
236
|
+
i, mode = DEFAULT_MODE
|
237
|
+
)
|
238
|
+
mode = DEFAULT_MODE if mode.nil?
|
239
|
+
if i.count('/') > 1
|
240
|
+
# ===================================================================== #
|
241
|
+
# We delegate towards FileUtils.mkdir_p() next, but we have to be
|
242
|
+
# careful - there may be no space left on the external device, so
|
243
|
+
# we have to rescue this situation.
|
244
|
+
# ===================================================================== #
|
245
|
+
begin
|
246
|
+
FileUtils.mkdir_p(i) unless Dir.exist? i
|
247
|
+
return true
|
248
|
+
rescue Errno::ENOSPC => error
|
249
|
+
opnn; e 'It appears to be the case that there is no space left on'
|
250
|
+
opnn; e 'the target device.'
|
251
|
+
pp error # And show the exact error as well.
|
252
|
+
end
|
253
|
+
else
|
254
|
+
unless File.directory? i
|
255
|
+
Dir.mkdir(i, mode)
|
256
|
+
return true # Return true just in case we ever need this information.
|
257
|
+
end
|
258
|
+
end
|
259
|
+
false
|
260
|
+
end; self.instance_eval { alias mkdir create_directory } # === BackupParadise.mkdir (mkdir tag)
|
261
|
+
|
262
|
+
# ========================================================================= #
|
263
|
+
# === BackupParadise.use_system_cp?
|
264
|
+
# ========================================================================= #
|
265
|
+
def self.use_system_cp?
|
266
|
+
if CONFIG.has_key?('use_system_cp')
|
267
|
+
if (CONFIG['use_system_cp'] == true)
|
268
|
+
return true
|
269
|
+
else
|
270
|
+
return false
|
271
|
+
end
|
272
|
+
else
|
273
|
+
return true
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
# ========================================================================= #
|
278
|
+
# === debug (debug tag)
|
279
|
+
#
|
280
|
+
# This is just "quick" debug output.
|
281
|
+
# ========================================================================= #
|
282
|
+
def debug
|
283
|
+
e
|
284
|
+
e ' Data directory: '+sfancy(data_directory?)
|
285
|
+
e " Main mount point: #{sfancy(mount_point?.to_s)}"
|
286
|
+
e
|
287
|
+
end
|
288
|
+
|
289
|
+
# ========================================================================= #
|
290
|
+
# === BackupParadise.backup
|
291
|
+
#
|
292
|
+
# Use this to backup something individually.
|
293
|
+
#
|
294
|
+
# To invoke this method, do:
|
295
|
+
#
|
296
|
+
# BackupParadise.backup(:audio, '/Mount/HDD1/')
|
297
|
+
#
|
298
|
+
# ========================================================================= #
|
299
|
+
def self.backup(
|
300
|
+
this_directory_or_file = '/home/x/songs/',
|
301
|
+
target_location = '/Mount/HDD1/',
|
302
|
+
be_verbose = true
|
303
|
+
)
|
304
|
+
if this_directory_or_file.is_a? Array
|
305
|
+
this_directory_or_file.each {|entry|
|
306
|
+
Backup.backup(entry, target_location, be_verbose)
|
307
|
+
}
|
308
|
+
else
|
309
|
+
this_directory_or_file = rds(this_directory_or_file)
|
310
|
+
case this_directory_or_file
|
311
|
+
# ===================================================================== #
|
312
|
+
# === :audio
|
313
|
+
# ===================================================================== #
|
314
|
+
when :audio, :audio_dir, :songs, :songs_dir, :default
|
315
|
+
this_directory_or_file = '/home/x/songs/'
|
316
|
+
end
|
317
|
+
target_location = target_location.to_s
|
318
|
+
e "Now backing up directory `#{sdir(this_directory_or_file)}"\
|
319
|
+
"` to `#{sdir(target_location)}`."
|
320
|
+
cpr( # defined in the file base.rb, meaning "copy recursively".
|
321
|
+
this_directory_or_file,
|
322
|
+
target_location,
|
323
|
+
be_verbose
|
324
|
+
)
|
325
|
+
rename_tab 'Backing up now ...'
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
# ========================================================================= #
|
330
|
+
# === BackupParadise.use_this_program_to_rename_tabs?
|
331
|
+
# ========================================================================= #
|
332
|
+
def self.use_this_program_to_rename_tabs?
|
333
|
+
if CONFIG.has_key?('use_this_program_to_rename_tabs')
|
334
|
+
# ===================================================================== #
|
335
|
+
# Obtain the program that we will use for renaming the tab.
|
336
|
+
# ===================================================================== #
|
337
|
+
CONFIG['use_this_program_to_rename_tabs']
|
338
|
+
else
|
339
|
+
:konsole # Default.
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
end
|