backup_paradise 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +452 -0
- data/backup_paradise.gemspec +50 -0
- data/bin/backup_for_ingrid +10 -0
- data/bin/backup_paradise +7 -0
- data/bin/windows_backup_paradise +9 -0
- data/doc/README.gen +390 -0
- data/doc/TODO.md +130 -0
- data/img/BackupParadise_Logo.png +0 -0
- data/lib/backup_paradise/actions/README.md +2 -0
- data/lib/backup_paradise/actions/backup.rb +62 -0
- data/lib/backup_paradise/base/base.rb +529 -0
- data/lib/backup_paradise/base/colours.rb +137 -0
- data/lib/backup_paradise/base/namespace.rb +16 -0
- data/lib/backup_paradise/base/tab.rb +47 -0
- data/lib/backup_paradise/colours/colours.rb +88 -0
- data/lib/backup_paradise/constants/constants.rb +162 -0
- data/lib/backup_paradise/gui/glimmer/libui/backup_for_ingrid/backup_for_ingrid.rb +87 -0
- data/lib/backup_paradise/gui/gtk2/OLD_backup.rb +165 -0
- data/lib/backup_paradise/gui/libui/backup_for_ingrid/backup_for_ingrid.rb +99 -0
- data/lib/backup_paradise/gui/shared_code/simple_backup_widget/simple_backup_widget_module.rb +0 -0
- data/lib/backup_paradise/gui/tk/backup.rb +108 -0
- data/lib/backup_paradise/gui/universal_widgets/simple_backup_widget/simple_backup_widget.rb +921 -0
- data/lib/backup_paradise/images/BACKUP_IMAGE.png +0 -0
- data/lib/backup_paradise/images/right_arrow.png +0 -0
- data/lib/backup_paradise/project/project.rb +40 -0
- data/lib/backup_paradise/requires/require_the_backup_paradise_project.rb +18 -0
- data/lib/backup_paradise/requires/require_yaml.rb +7 -0
- data/lib/backup_paradise/tab/tab.rb +87 -0
- data/lib/backup_paradise/toplevel_methods/cliner.rb +16 -0
- data/lib/backup_paradise/toplevel_methods/config.rb +86 -0
- data/lib/backup_paradise/toplevel_methods/create_and_remove.rb +63 -0
- data/lib/backup_paradise/toplevel_methods/e.rb +16 -0
- data/lib/backup_paradise/toplevel_methods/esystem.rb +19 -0
- data/lib/backup_paradise/toplevel_methods/files_and_directories.rb +181 -0
- data/lib/backup_paradise/toplevel_methods/help.rb +93 -0
- data/lib/backup_paradise/toplevel_methods/misc.rb +153 -0
- data/lib/backup_paradise/toplevel_methods/mountpoint.rb +188 -0
- data/lib/backup_paradise/toplevel_methods/opnn.rb +27 -0
- data/lib/backup_paradise/utility_scripts/backup/backup.rb +1942 -0
- data/lib/backup_paradise/version/version.rb +19 -0
- data/lib/backup_paradise/windows/README.md +1 -0
- data/lib/backup_paradise/windows/windows.rb +101 -0
- data/lib/backup_paradise/www/backup.cgi +63 -0
- data/lib/backup_paradise/yaml/config.yml +82 -0
- data/lib/backup_paradise.rb +5 -0
- data/test/testing_toplevel_functionality.rb +11 -0
- metadata +192 -0
Binary file
|
Binary file
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/project/project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module BackupParadise
|
8
|
+
|
9
|
+
# ========================================================================= #
|
10
|
+
# === PROJECT_BASE_DIRECTORY
|
11
|
+
# ========================================================================= #
|
12
|
+
PROJECT_BASE_DIRECTORY =
|
13
|
+
File.absolute_path("#{__dir__}/..")+'/'
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === BackupParadise.project_base_dir?
|
17
|
+
# ========================================================================= #
|
18
|
+
def self.project_base_dir?
|
19
|
+
BackupParadise::PROJECT_BASE_DIRECTORY
|
20
|
+
end; self.instance_eval { alias project_base_directory? project_base_dir? } # === BackupParadise.project_base_directory?
|
21
|
+
|
22
|
+
# ========================================================================= #
|
23
|
+
# === BackupParadise.project_yaml_dir?
|
24
|
+
# ========================================================================= #
|
25
|
+
def self.project_yaml_dir?
|
26
|
+
"#{BackupParadise::PROJECT_BASE_DIRECTORY}yaml/"
|
27
|
+
end
|
28
|
+
|
29
|
+
# ========================================================================= #
|
30
|
+
# === BackupParadise.file_config_yaml
|
31
|
+
#
|
32
|
+
# This method will return the proper path to the config.yml file
|
33
|
+
# in use.
|
34
|
+
# ========================================================================= #
|
35
|
+
def self.file_config_yaml
|
36
|
+
"#{BackupParadise.project_yaml_dir?}config.yml"
|
37
|
+
end; self.instance_eval { alias file_config file_config_yaml } # === BackupParadise.file_config
|
38
|
+
self.instance_eval { alias file_config? file_config_yaml } # === BackupParadise.file_config?
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# When you wish to require the whole project, this is the file to go for.
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'backup_paradise/requires/require_the_backup_paradise_project.rb'
|
8
|
+
# =========================================================================== #
|
9
|
+
require 'backup_paradise/project/project.rb'
|
10
|
+
require 'backup_paradise/requires/require_yaml.rb'
|
11
|
+
require 'backup_paradise/actions/backup.rb'
|
12
|
+
require 'backup_paradise/colours/colours.rb'
|
13
|
+
require 'backup_paradise/constants/constants.rb'
|
14
|
+
require 'backup_paradise/toplevel_methods/e.rb'
|
15
|
+
require 'backup_paradise/toplevel_methods/cliner.rb'
|
16
|
+
require 'backup_paradise/utility_scripts/backup/backup.rb'
|
17
|
+
require 'backup_paradise/tab/tab.rb'
|
18
|
+
require 'backup_paradise/windows/windows.rb'
|
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/requires/require_yaml.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'yaml'
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === BackupParadise::Tab
|
6
|
+
#
|
7
|
+
# This file handles tab-related activities, most normally renaming a tab.
|
8
|
+
#
|
9
|
+
# Right now we have only some support for KDE tabs and mrxvt tabs.
|
10
|
+
# =========================================================================== #
|
11
|
+
# require 'backup_paradise/tab/tab.rb'
|
12
|
+
# =========================================================================== #
|
13
|
+
module BackupParadise
|
14
|
+
|
15
|
+
module Tab # === BackupParadise::Tab
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'roebe/classes/mrxvt_options.rb'
|
19
|
+
rescue LoadError; end
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === BackupParadise::Tab.rename_tab
|
23
|
+
#
|
24
|
+
# This method does some additional checks before invoking the method
|
25
|
+
# set_mrxvt_tab_title. set_konsole_tab_title() may work, if the
|
26
|
+
# user at hand has the roebe gem installed (aka, on my home system).
|
27
|
+
# ========================================================================= #
|
28
|
+
def self.rename_tab(
|
29
|
+
i = :mrxvt,
|
30
|
+
optional_title = 'Backup', # <- This is the new title.
|
31
|
+
use_this_program_to_rename_tabs = :mrxvt
|
32
|
+
)
|
33
|
+
case i.to_sym # case tag
|
34
|
+
# ======================================================================= #
|
35
|
+
# === :konsole
|
36
|
+
#
|
37
|
+
# This is the default.
|
38
|
+
# ======================================================================= #
|
39
|
+
when :konsole,
|
40
|
+
:default
|
41
|
+
set_konsole_tab_title(optional_title)
|
42
|
+
# ======================================================================= #
|
43
|
+
# === :mrxvt
|
44
|
+
# ======================================================================= #
|
45
|
+
when :mrxvt
|
46
|
+
set_mrxvt_tab_title(optional_title) # Defined in this module here.
|
47
|
+
# ======================================================================= #
|
48
|
+
# === :blank
|
49
|
+
#
|
50
|
+
# This entry point re-sets the title of the terminal tab again to
|
51
|
+
# empty.
|
52
|
+
# ======================================================================= #
|
53
|
+
when :blank
|
54
|
+
case use_this_program_to_rename_tabs
|
55
|
+
when :konsole
|
56
|
+
set_konsole_tab_title(optional_title)
|
57
|
+
when :mrxvt
|
58
|
+
set_mrxvt_tab_title(optional_title)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# ========================================================================= #
|
64
|
+
# === BackupParadise::Tab.set_mrxvt_tab_title
|
65
|
+
# ========================================================================= #
|
66
|
+
def self.set_mrxvt_tab_title(i)
|
67
|
+
if Object.const_defined? :Roebe
|
68
|
+
begin
|
69
|
+
require 'roebe/classes/mrxvt_options.rb'
|
70
|
+
rescue LoadError; end
|
71
|
+
Roebe::MrxvtOptions.set_title(i)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# ========================================================================= #
|
76
|
+
# === BackupParadise::Tab.set_konsole_tab_title
|
77
|
+
# ========================================================================= #
|
78
|
+
def self.set_konsole_tab_title(i)
|
79
|
+
if Object.const_defined? :Roebe
|
80
|
+
begin
|
81
|
+
require 'roebe/classes/kde/kde_konsole.rb'
|
82
|
+
rescue LoadError; end
|
83
|
+
Roebe.rename_konsole_title_to(i, :be_quiet)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end; 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/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,86 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/toplevel_methods/config.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module BackupParadise
|
8
|
+
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
require 'backup_paradise/project/project.rb'
|
12
|
+
|
13
|
+
_ = BackupParadise.file_config_yaml # bl $RUBY_BACKUP/YAML/config.yml
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === CONFIG
|
17
|
+
#
|
18
|
+
# Keep track of the configuration of the backup-paradise project.
|
19
|
+
# ========================================================================= #
|
20
|
+
if File.exist? _
|
21
|
+
CONFIG = YAML.load_file(_) # This will be a Hash.
|
22
|
+
else
|
23
|
+
CONFIG = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
# ========================================================================= #
|
27
|
+
# === BackupParadise.config?
|
28
|
+
#
|
29
|
+
# Toplevel query method over the config-hash.
|
30
|
+
# ========================================================================= #
|
31
|
+
def self.config?
|
32
|
+
CONFIG
|
33
|
+
end
|
34
|
+
|
35
|
+
# ========================================================================= #
|
36
|
+
# === BackupParadise.use_this_program_to_rename_tabs?
|
37
|
+
# ========================================================================= #
|
38
|
+
def self.use_this_program_to_rename_tabs?
|
39
|
+
if CONFIG.has_key?('use_this_program_to_rename_tabs')
|
40
|
+
# ===================================================================== #
|
41
|
+
# Obtain the program that we will use for renaming the tab.
|
42
|
+
# ===================================================================== #
|
43
|
+
CONFIG['use_this_program_to_rename_tabs'].to_sym
|
44
|
+
else
|
45
|
+
:konsole # Default.
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# ========================================================================= #
|
50
|
+
# === BackupParadise.use_system_cp?
|
51
|
+
# ========================================================================= #
|
52
|
+
def self.use_system_cp?
|
53
|
+
if CONFIG.has_key?('use_system_cp')
|
54
|
+
return CONFIG['use_system_cp']
|
55
|
+
else
|
56
|
+
return true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# ========================================================================= #
|
61
|
+
# === BackupParadise.show_popup_notification?
|
62
|
+
# ========================================================================= #
|
63
|
+
def self.show_popup_notification?
|
64
|
+
if CONFIG.has_key?('show_popup_notification')
|
65
|
+
if (CONFIG['show_popup_notification'] == true)
|
66
|
+
return true
|
67
|
+
else
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
else
|
71
|
+
return true
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# ========================================================================= #
|
76
|
+
# === BackupParadise.backup_these_directories?
|
77
|
+
# ========================================================================= #
|
78
|
+
def self.backup_these_directories?
|
79
|
+
if CONFIG.has_key?('backup_these_directories')
|
80
|
+
return CONFIG['backup_these_directories']
|
81
|
+
else
|
82
|
+
return []
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/toplevel_methods/create_and_remove.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module BackupParadise
|
8
|
+
|
9
|
+
require 'fileutils'
|
10
|
+
require 'backup_paradise/toplevel_methods/e.rb'
|
11
|
+
require 'backup_paradise/colours/colours.rb'
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === BackupParadise.remove_directory
|
15
|
+
# ========================================================================= #
|
16
|
+
def self.remove_directory(i)
|
17
|
+
i = rds(i).strip
|
18
|
+
unless i == '/' # Tiny "safeguard".
|
19
|
+
FileUtils.rm_rf(i) if File.directory?(i)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# ========================================================================= #
|
24
|
+
# === BackupParadise.remove_this_file
|
25
|
+
#
|
26
|
+
# Use this method to remove a file.
|
27
|
+
# ========================================================================= #
|
28
|
+
def self.remove_this_file(this_file)
|
29
|
+
e "Removing the file `#{sfile(this_file)}` now."
|
30
|
+
FileUtils.rm(this_file)
|
31
|
+
end
|
32
|
+
|
33
|
+
# ========================================================================= #
|
34
|
+
# === BackupParadise.remove
|
35
|
+
#
|
36
|
+
# Easier wrapper when we need to remove something, be it a directory
|
37
|
+
# or a file or a symlink.
|
38
|
+
# ========================================================================= #
|
39
|
+
def self.remove(i)
|
40
|
+
if i.is_a? Array
|
41
|
+
i.each {|entry| remove(entry) }
|
42
|
+
else
|
43
|
+
i = rds(i)
|
44
|
+
_ = i.dup
|
45
|
+
if File.directory? i
|
46
|
+
_ = sdir(i)
|
47
|
+
elsif File.file?(i)
|
48
|
+
_ = sfile(i)
|
49
|
+
else # else it will just be fancy.
|
50
|
+
_ = sfancy(i)
|
51
|
+
end
|
52
|
+
e "Trying to remove `#{_}` next."
|
53
|
+
if File.directory?(i)
|
54
|
+
remove_directory(i)
|
55
|
+
elsif File.file?(i)
|
56
|
+
remove_this_file(i) # Defined in this file here.
|
57
|
+
else
|
58
|
+
e 'Not found the action: "'+sfancy(i)+'"'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
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,19 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'backup_paradise/toplevel_methods/esystem.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
module BackupParadise
|
8
|
+
|
9
|
+
require 'backup_paradise/toplevel_methods/e.rb'
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === BackupParadise.esystem
|
13
|
+
# ========================================================================= #
|
14
|
+
def self.esystem(i = '')
|
15
|
+
e i
|
16
|
+
system i
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# This file guarantees to require fileutils, so other .rb files do not
|
6
|
+
# have to do so.
|
7
|
+
# =========================================================================== #
|
8
|
+
# require 'backup_paradise/toplevel_methods/files_and_directories.rb'
|
9
|
+
# =========================================================================== #
|
10
|
+
module BackupParadise
|
11
|
+
|
12
|
+
require 'fileutils'
|
13
|
+
require 'backup_paradise/constants/constants.rb'
|
14
|
+
require 'backup_paradise/toplevel_methods/esystem.rb'
|
15
|
+
require 'backup_paradise/toplevel_methods/opnn.rb'
|
16
|
+
|
17
|
+
# ========================================================================= #
|
18
|
+
# === BackupParadise.copy_recursively
|
19
|
+
#
|
20
|
+
# This method can be used to copy the source to the target in a
|
21
|
+
# recursive manner.
|
22
|
+
#
|
23
|
+
# The third argument to this method, called `be_verbose`, will
|
24
|
+
# feedback what is done, to the user, if it has a value of true.
|
25
|
+
# Symbols such as :be_verbose can be used as an "alias" to true.
|
26
|
+
# If it is set to false, or :be_silent, then no output will be
|
27
|
+
# issued to the user.
|
28
|
+
# ========================================================================= #
|
29
|
+
def self.copy_recursively(
|
30
|
+
this_directory, # from (also called source)
|
31
|
+
backup_to_this_target, # to (also called target)
|
32
|
+
be_verbose = :be_verbose
|
33
|
+
)
|
34
|
+
this_directory = this_directory.dup if this_directory.frozen?
|
35
|
+
if this_directory.include? '*'
|
36
|
+
require 'convert_global_env'
|
37
|
+
this_directory = ConvertGlobalEnv[this_directory].dup
|
38
|
+
end
|
39
|
+
this_directory = rds(this_directory)
|
40
|
+
backup_to_this_target = rds(backup_to_this_target)
|
41
|
+
use_system_cp = use_system_cp?
|
42
|
+
case be_verbose
|
43
|
+
when :be_verbose
|
44
|
+
be_verbose = true
|
45
|
+
end
|
46
|
+
begin
|
47
|
+
raw_file_check = this_directory.dup.delete('*') # No '*' here.
|
48
|
+
if File.directory?(raw_file_check)
|
49
|
+
if use_system_cp
|
50
|
+
# ================================================================= #
|
51
|
+
# In that case we will simply use system cp.
|
52
|
+
# ================================================================= #
|
53
|
+
esystem "cp --recursive --verbose #{this_directory} #{backup_to_this_target}"
|
54
|
+
else
|
55
|
+
FileUtils.cp_r(
|
56
|
+
this_directory,
|
57
|
+
backup_to_this_target,
|
58
|
+
verbose: be_verbose
|
59
|
+
)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
e 'No directory exists at the path '+sdir(this_directory)+'.'
|
63
|
+
end
|
64
|
+
rescue Exception => error
|
65
|
+
opnn; e 'An error occurred in the method '+
|
66
|
+
__method__.to_s+'(): '+error.class.to_s
|
67
|
+
pp error
|
68
|
+
end
|
69
|
+
end; self.instance_eval { alias cpr copy_recursively } # === BackupParadise.cpr
|
70
|
+
self.instance_eval { alias backup_this_directory_if_it_exists copy_recursively } # === BackupParadise.backup_this_directory_if_it_exists
|
71
|
+
|
72
|
+
# ========================================================================= #
|
73
|
+
# === BackupParadise.size?
|
74
|
+
#
|
75
|
+
# Gives you the size of the given subdirectory.
|
76
|
+
#
|
77
|
+
# Usage Example:
|
78
|
+
#
|
79
|
+
# BackupParadise.size?(ENV['J']) # => 1_396_436_232
|
80
|
+
# BackupParadise.size?(BackupParadise::AUDIO_DIR) # => 1_396_436_232
|
81
|
+
#
|
82
|
+
# ========================================================================= #
|
83
|
+
def self.size?(subdir_part)
|
84
|
+
size = 0 # Default.
|
85
|
+
begin
|
86
|
+
subdir_part = "#{subdir_part}/**/*"
|
87
|
+
results = Dir[subdir_part]
|
88
|
+
size = results.inject(0) { |sum, entry|
|
89
|
+
result = 0
|
90
|
+
result = sum + File.size(entry) if File.exist? entry
|
91
|
+
result
|
92
|
+
}
|
93
|
+
rescue; end # Make it failsave.
|
94
|
+
return size.to_s
|
95
|
+
end
|
96
|
+
|
97
|
+
# ========================================================================= #
|
98
|
+
# === BackupParadise.create_directory
|
99
|
+
#
|
100
|
+
# Dir.mkdir would be an alternative. We require DEFAULT_MODE to be set
|
101
|
+
# before we can use this method here - hence why we require the file
|
102
|
+
# constants.rb.
|
103
|
+
# ========================================================================= #
|
104
|
+
def self.create_directory(
|
105
|
+
i, mode = DEFAULT_MODE
|
106
|
+
)
|
107
|
+
mode = DEFAULT_MODE if mode.nil?
|
108
|
+
if i.count('/') > 1
|
109
|
+
# ===================================================================== #
|
110
|
+
# We delegate towards FileUtils.mkdir_p() next, but we have to be
|
111
|
+
# careful - there may be no space left on the external device, so
|
112
|
+
# we have to rescue this situation.
|
113
|
+
# ===================================================================== #
|
114
|
+
begin
|
115
|
+
FileUtils.mkdir_p(i) unless Dir.exist? i
|
116
|
+
return true
|
117
|
+
rescue Errno::ENOSPC => error
|
118
|
+
opnn; e 'It appears to be the case that there is no space left on'
|
119
|
+
opnn; e 'the target device.'
|
120
|
+
pp error # And show the exact error as well.
|
121
|
+
end
|
122
|
+
else
|
123
|
+
unless File.directory? i
|
124
|
+
Dir.mkdir(i, mode)
|
125
|
+
return true # Return true just in case we ever need this information.
|
126
|
+
end
|
127
|
+
end
|
128
|
+
false
|
129
|
+
end; self.instance_eval { alias mkdir create_directory } # === BackupParadise.mkdir (mkdir tag)
|
130
|
+
|
131
|
+
# ========================================================================= #
|
132
|
+
# === BackupParadise.size_in_gigabytes?
|
133
|
+
#
|
134
|
+
# This method will return the size of the target directory in gigabytes.
|
135
|
+
# ========================================================================= #
|
136
|
+
def self.size_in_gigabytes?(i = BackupParadise::AUDIO_DIR)
|
137
|
+
(
|
138
|
+
BackupParadise.size?(i).to_f / 1024.0 / 1024.0 / 1000.0
|
139
|
+
).round(1).to_f
|
140
|
+
end
|
141
|
+
|
142
|
+
# ========================================================================= #
|
143
|
+
# === BackupParadise.change_directory (cd tag, chdir tag)
|
144
|
+
#
|
145
|
+
# This should no longer be required.
|
146
|
+
# ========================================================================= #
|
147
|
+
def self.change_directory(i)
|
148
|
+
Dir.chdir(i) if i and File.directory?(i)
|
149
|
+
end; self.instance_eval { alias cd change_directory } # === BackupParadise.cd
|
150
|
+
|
151
|
+
# ========================================================================= #
|
152
|
+
# === BackupParadise.copy_file
|
153
|
+
#
|
154
|
+
# Copy a file with this method consistently.
|
155
|
+
# ========================================================================= #
|
156
|
+
def self.copy_file(file, where_to)
|
157
|
+
begin
|
158
|
+
FileUtils.cp(file, where_to)
|
159
|
+
rescue Errno::ENOSPC # Not enough space on target device.
|
160
|
+
opnn; e 'We must exit now - there is not enough space left on the '
|
161
|
+
opnn; e 'target hdd.'
|
162
|
+
rescue Errno::EINVAL # Invalid argument @ rb_sysopen
|
163
|
+
opnn; e 'The file can not be copied, possibly because it '\
|
164
|
+
'contains a german umlaut.'
|
165
|
+
opnn; e 'We will however continue nonetheless.'
|
166
|
+
rescue Errno::EISDIR
|
167
|
+
opnn; e 'We currently do not copy directories, only files.'
|
168
|
+
rescue Errno::EILSEQ => error
|
169
|
+
opnn; e "It seems that we have an invalid or incomplete multibyte "\
|
170
|
+
"or wide-character at file `#{sfile(file.to_s)}`."
|
171
|
+
opnn; e 'We thus can not copy this file.'
|
172
|
+
pp error
|
173
|
+
rescue Exception => error # In lucky days, we will never reach this here.
|
174
|
+
pp error
|
175
|
+
opnn; e 'The above error should be intercepted - please add it,'
|
176
|
+
opnn; e 'then press the ENTER key in order to continue.'
|
177
|
+
$stdin.gets.chomp # We will remove this line here eventually.
|
178
|
+
end
|
179
|
+
end; self.instance_eval { alias copy_this_file copy_file } # === BackupParadise.copy_this_file
|
180
|
+
|
181
|
+
end
|
@@ -0,0 +1,93 @@
|
|
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
|
+
module BackupParadise
|
8
|
+
|
9
|
+
require 'backup_paradise/toplevel_methods/cliner.rb'
|
10
|
+
require 'backup_paradise/colours/colours.rb'
|
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 ::Colours.rev+
|
29
|
+
' - Please note that you can use any order for the arguments.'
|
30
|
+
e
|
31
|
+
e 'Documented help options are:'
|
32
|
+
e
|
33
|
+
e ' rbackup --programs-dir # Back up the /Programs/ directory quickly'
|
34
|
+
e ' rbackup --backup-to=/PATH # Back up into the PATH directory.'
|
35
|
+
e
|
36
|
+
e 'The following options are NOT yet tested!'
|
37
|
+
e
|
38
|
+
e " - Pass #{sfancy('tohdd')} to backup to the hdd (usually "\
|
39
|
+
"this is the second harddisc)."
|
40
|
+
e
|
41
|
+
e ' - Pass '+sfancy('tousb ')+'to backup to the (first) usb media.'
|
42
|
+
e ' (Aliases exist, such as '+sfancy('usb1')+sfancy(' usb2')+
|
43
|
+
sfancy(' usb3')+' and so forth)'
|
44
|
+
e
|
45
|
+
e ' - Pass '+sfancy('data_only ')+'to backup only the '+
|
46
|
+
sdir(HOME_DIRECTORY_OF_THE_USER_X+'DATA/')+' directory.'
|
47
|
+
e
|
48
|
+
e ' - In general you can backup individual directories as well.'
|
49
|
+
e
|
50
|
+
e ' Examples for this functionality:'
|
51
|
+
e
|
52
|
+
e sfancy(' rbackup audio')
|
53
|
+
e sfancy(' rbackup data')
|
54
|
+
e
|
55
|
+
e ' - You can also chain together commands.'
|
56
|
+
e
|
57
|
+
e ' Example for chaining together commands:'
|
58
|
+
e
|
59
|
+
e sfancy(' rbackup data_only usb1')
|
60
|
+
e sfancy(' rbackup audio_only usb1')
|
61
|
+
e
|
62
|
+
e ' - You can backup the /Programs directory.'
|
63
|
+
e
|
64
|
+
e ' Issue the following command here:'
|
65
|
+
e
|
66
|
+
e sfancy(' rbackup usb1 programs')
|
67
|
+
e sfancy(' rbackup usb1 /Programs')
|
68
|
+
e
|
69
|
+
e ' - If you do the following.'
|
70
|
+
e ' Examples:'
|
71
|
+
e sfancy(' rbackup no-mount1')
|
72
|
+
e ' Then we wont try to (re)mount the device again.'
|
73
|
+
e
|
74
|
+
e 'If you want to show the time it took to backup the last some'
|
75
|
+
e 'backup-jobs, use this commandline flag:'
|
76
|
+
e
|
77
|
+
e sfancy(' rbackup --logfile')
|
78
|
+
e
|
79
|
+
e 'To simply backup into the current working '\
|
80
|
+
'directory (cwd, pwd)'
|
81
|
+
e 'use:'
|
82
|
+
e
|
83
|
+
e sfancy(' rbackup --pwd')
|
84
|
+
e
|
85
|
+
e 'To use the GTK3 GUI, you could try:'
|
86
|
+
e
|
87
|
+
e sfancy(' rbackup --gui')
|
88
|
+
e
|
89
|
+
cliner
|
90
|
+
e
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|