Class: BackupParadise::Backup
- Defined in:
- lib/backup_paradise/utility_scripts/backup/backup.rb
Overview
BackupParadise::Backup
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- MINIMAL_FILESIZE =
#
MINIMAL_FILESIZE
#
5 * (1000 ** 3)
- FILE_BACKUP_LOG =
'/tmp/backup.log'
- TRY_TO_SHOW_BACKUP_COMPLETE_MESSAGE_VIA_LIBUI =
#
TRY_TO_SHOW_BACKUP_COMPLETE_MESSAGE_VIA_LIBUI
If the following constant is true then this class will try to make use of libui and the libui_paradise gem to show a little libui message box (a window) about how the backup action is now complete.
#
true
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === BackupParadise::Backup[] ========================================================================= #.
Instance Method Summary collapse
-
#are_we_on_windows? ⇒ Boolean
# === are_we_on_windows? ========================================================================= #.
-
#are_we_trying_to_backup_to_a_local_harddisc? ⇒ Boolean
# === are_we_trying_to_backup_to_a_local_harddisc? ========================================================================= #.
-
#backup_into_the_default_chroot_directory(i = :chroot) ⇒ Object
# === backup_into_the_default_chroot_directory (chroot tag) ========================================================================= #.
-
#backup_the_audio_directory(i = DIRECTORY_CONTAINING_ALL_SONGS, copy_only_missing_audio_files = true) ⇒ Object
(also: #try_to_backup_the_audio_directory, #backup_audio_directory)
# === backup_the_audio_directory (audio tag, audio dir tag).
-
#backup_the_audio_directory_then_exit ⇒ Object
# === backup_the_audio_directory_then_exit.
-
#backup_the_books_directory(target_directory = BOOKS_DIRECTORY) ⇒ Object
(also: #backup_only_books_directory, #backup_books_directory)
# === backup_the_books_directory (data tag).
-
#backup_the_data_directory(target_directory = DATA_DIRECTORY) ⇒ Object
(also: #backup_only_data_directory, #backup_data_directory)
# === backup_the_data_directory (data tag).
-
#backup_the_data_directory_then_exit ⇒ Object
(also: #backup_data_directory_then_exit)
# === backup_the_data_directory_then_exit.
-
#backup_the_programs_directory(target_directory = PROGRAMS_DIRECTORY) ⇒ Object
# === backup_the_programs_directory This method can be used to backup the /Programs directory.
-
#backup_the_source_directory(target_directory = SOURCE_DIRECTORY) ⇒ Object
# === backup_src_directory (src tag).
-
#backup_the_studium_directory(target_directory = STUDIUM_DIRECTORY) ⇒ Object
# === backup_the_studium_directory ========================================================================= #.
-
#backup_the_system_directory(target_directory = SYSTEM_SETTINGS_DIRECTORY) ⇒ Object
(also: #backup_system_directory)
# === backup_the_system_directory This method can be used to backup the “/System/Settings/” directory, as it may be found in GoboLinux.
-
#backup_the_video_directory(target_directory = VIDEO_DIRECTORY) ⇒ Object
# === backup_the_video_directory ========================================================================= #.
-
#backup_this_directory(i, copy_to_this_target_directory = nil, shall_we_sync = true) ⇒ Object
# === backup_this_directory.
-
#backup_to_this_target? ⇒ Boolean
# === backup_to_this_target? ========================================================================= #.
-
#backup_which_directories? ⇒ Boolean
# === backup_which_directories? ========================================================================= #.
-
#can_not_backup_this_directory_as_it_does_not_exist(i) ⇒ Object
# === can_not_backup_this_directory_as_it_does_not_exist ========================================================================= #.
-
#commandline_arguments? ⇒ Boolean
# === commandline_arguments? ========================================================================= #.
-
#consider_creating_a_log_file(n_seconds) ⇒ Object
# === consider_creating_a_log_file.
-
#consider_removing_all_but_one_log_file ⇒ Object
# === consider_removing_all_but_one_log_file ========================================================================= #.
-
#consider_renaming_all_old_last_backup_directories ⇒ Object
# === consider_renaming_all_old_last_backup_directories.
-
#create_a_symlink_pointing_to_that_directory_that_was_just_created ⇒ Object
(also: #create_symlink_to_last_backup_directory)
# === create_a_symlink_pointing_to_that_directory_that_was_just_created.
-
#create_file_keeping_track_of_when_the_last_backup_happened(use_this_as_timestamp = use_this_as_timestamp? ) ⇒ Object
(also: #store_when_was_the_last_backup)
# === create_file_keeping_track_of_when_the_last_backup_happened.
-
#create_the_directory_containing_the_last_backup ⇒ Object
# === create_the_directory_containing_the_last_backup ========================================================================= #.
-
#create_the_log_last_backup_file ⇒ Object
(also: #create_log_file)
# === create_the_log_last_backup_file (log tag).
-
#date? ⇒ Boolean
#.
-
#default_tab_title ⇒ Object
# === default_tab_title ========================================================================= #.
-
#determine_end_time ⇒ Object
# === determine_end_time ========================================================================= #.
-
#determine_the_current_timestamp ⇒ Object
# === determine_the_current_timestamp ========================================================================= #.
-
#determine_the_starting_time ⇒ Object
(also: #determine_starting_time)
# === determine_the_starting_time ========================================================================= #.
-
#determine_the_target_mountpoint(i = '/Mount/USB1/') ⇒ Object
# === determine_the_target_mountpoint.
-
#determine_where_to_backup_to_exactly(i = mountpoint? ) ⇒ Object
# === determine_where_to_backup_to_exactly.
-
#determine_whether_the_target_harddisc_is_a_ntfs_system ⇒ Object
# === determine_whether_the_target_harddisc_is_a_ntfs_system ========================================================================= #.
-
#do_not_perform_the_regular_backup_routine ⇒ Object
# === do_not_perform_the_regular_backup_routine ========================================================================= #.
-
#do_perform_the_backup_tasks ⇒ Object
(also: #start_backup, #backup_everything, #do_backup)
# === do_perform_the_backup_tasks (all tag).
-
#do_show_popup ⇒ Object
(also: #show_popup)
# === do_show_popup ========================================================================= #.
-
#do_sync ⇒ Object
(also: #synchronize)
# === do_sync.
-
#do_use_simplified_directory ⇒ Object
# === do_use_simplified_directory.
-
#ensure_trailing_backslash_for(i) ⇒ Object
# === ensure_trailing_backslash_for ========================================================================= #.
-
#first_argument? ⇒ Boolean
(also: #first?)
# === first_argument? ========================================================================= #.
-
#initialize(commandline_arguments = nil, run_already = true, &block) ⇒ Backup
constructor
# === initialize Invocation example:.
-
#is_target_harddisc_a_ntfs_system? ⇒ Boolean
# === is_target_harddisc_a_ntfs_system?.
-
#is_the_harddisc_properly_mounted? ⇒ Boolean
# === is_the_harddisc_properly_mounted? ========================================================================= #.
-
#last_backup_directory? ⇒ Boolean
# === last_backup_directory? ========================================================================= #.
-
#menu(i = commandline_arguments? ) ⇒ Object
# === menu (menu tag) ========================================================================= #.
-
#mountpoint? ⇒ Boolean
(also: #mounted_at?, #target_base_directory?)
# === mountpoint? ========================================================================= #.
-
#opnn(i = NAMESPACE) ⇒ Object
# === opnn ========================================================================= #.
-
#perform_the_regular_backup_routine? ⇒ Boolean
# === perform_the_regular_backup_routine? ========================================================================= #.
-
#popup_notification(what = :backup_complete) ⇒ Object
# === popup_notification.
-
#report_time_difference ⇒ Object
# === report_time_difference.
-
#report_todays_date ⇒ Object
# === report_todays_date ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#return_all_log_files(from_where = mounted_at? ) ⇒ Object
# === return_all_log_files ========================================================================= #.
-
#return_default_target_directory_from_this_input(i) ⇒ Object
# === return_default_target_directory_from_this_input ========================================================================= #.
-
#return_the_assumed_mountpoint_from_this_input(i) ⇒ Object
# === return_the_assumed_mountpoint_from_this_input ========================================================================= #.
-
#return_the_songs_directory ⇒ Object
# === return_the_songs_directory ========================================================================= #.
-
#return_this_absolute_directory(i) ⇒ Object
# === return_this_absolute_directory ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
-
#sanitize_the_commandline_arguments(hash = commandline_arguments? ) ⇒ Object
# === sanitize_the_commandline_arguments.
-
#set_commandline_arguments(i = ARGV) ⇒ Object
# === set_commandline_arguments ========================================================================= #.
-
#set_last_backup_directory(i) ⇒ Object
# === set_last_backup_directory ========================================================================= #.
-
#set_mountpoint(i) ⇒ Object
(also: #set_backup_to_this_target, #set_target_mountpoint)
# === set_mountpoint ========================================================================= #.
-
#show_available_mountpoints ⇒ Object
# === show_available_mountpoints.
-
#show_available_mountpoints_then_exit ⇒ Object
# === show_available_mountpoints_then_exit ========================================================================= #.
-
#show_backup_complete_message ⇒ Object
(also: #all_done, #show_all_is_done_message, #all_done_message)
# === show_backup_complete_message.
-
#show_help ⇒ Object
(also: #display_help)
# === show_help ========================================================================= #.
-
#show_popup_notification? ⇒ Boolean
# === show_popup_notification? ========================================================================= #.
-
#show_the_logfile ⇒ Object
# === show_the_logfile.
-
#show_welcome_message ⇒ Object
# === show_welcome_message ========================================================================= #.
-
#simplify_the_directory_layout? ⇒ Boolean
# === simplify_the_directory_layout? ========================================================================= #.
-
#start_the_gtk3_bindings ⇒ Object
# === start_the_gtk3_bindings.
-
#try_to_backup_the_autogenerated_directory(i = AUTOGENERATED_DIRECTORY) ⇒ Object
(also: #backup_autogenerated_directory, #backup_the_autogenerated_directory)
# === try_to_backup_the_autogenerated_directory ========================================================================= #.
-
#try_to_show_backup_complete_message_via_libui ⇒ Object
# === try_to_show_backup_complete_message_via_libui.
-
#try_to_unmount_the_device ⇒ Object
# === try_to_unmount_the_device.
-
#unmount(what = :hdd) ⇒ Object
# === unmount.
-
#use_this_as_timestamp? ⇒ Boolean
# === use_this_as_timestamp? ========================================================================= #.
-
#verbose_create_a_directory_at_this_position(this_position, use_this_permission = 0754) ⇒ Object
# === verbose_create_a_directory_at_this_position.
Methods inherited from Base
#all_important_directories?, #append_what_into, #cd_to_the_mounted_device, #chdir, #cliner, #copy_file, #copy_recursively, #create_directory, #cyan, #data_directory?, #dd_mm_yyyy, #delete_files, #delete_symlink, #do_symlink, #e, #esystem, #exit_program, #has_superuser_abilities?, #hh_mm_ss, #home_dir_of_user_x?, #is_on_roebe?, #is_symlink?, #lightcoral, #n_files_in?, #no_file_exists_at, #no_such_directory_exists_at, #no_target_at, #opne, #orangered, #print_rev, #rds, #register_sigint, #remove, #remove_directory, #remove_file, #rename, #rename_tab, #report_total_size_of, #return_all_symlinks_from_this_directory, #return_current_date_and_time, #rev, #rosybrown, #royalblue, #sdir, #seagreen, #sfancy, #sfile, #simp, #size?, #steelblue, #tab_title, #target_hdd_does_not_have_enough_space_left?, #target_mountpoint?, #tomato, #use_colours?, #use_system_cp?, #use_this_program_to_rename_tabs?, #write_what_into
Constructor Details
#initialize(commandline_arguments = nil, run_already = true, &block) ⇒ Backup
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 75 def initialize( commandline_arguments = nil, run_already = true, &block ) register_sigint reset if commandline_arguments if commandline_arguments.is_a?(Symbol) case commandline_arguments # =================================================================== # # === :do_not_run_yet # =================================================================== # when :do_not_run_yet run_already = false end else set_commandline_arguments( commandline_arguments ) end end case run_already # ======================================================================= # # === :do_not_run_yet # ======================================================================= # when :do_not_run_yet run_already = false end # ======================================================================= # # === Handle blocks given next # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :do_not_run_yet # ===================================================================== # when :do_not_run_yet run_already = false # ===================================================================== # # === :we_are_on_windows # ===================================================================== # when :we_are_on_windows @internal_hash[:are_we_on_windows] = true end end run if run_already end |
Class Method Details
.[](i = '') ⇒ Object
#
BackupParadise::Backup[]
#
1035 1036 1037 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1035 def self.[](i = '') new(i) end |
Instance Method Details
#are_we_on_windows? ⇒ Boolean
#
are_we_on_windows?
#
1752 1753 1754 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1752 def are_we_on_windows? @internal_hash[:are_we_on_windows] end |
#are_we_trying_to_backup_to_a_local_harddisc? ⇒ Boolean
#
are_we_trying_to_backup_to_a_local_harddisc?
#
1917 1918 1919 1920 1921 1922 1923 1924 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1917 def case mountpoint? when /HDD/ # e g. @mountpoint="/Mount/HDD1/" true else false end end |
#backup_into_the_default_chroot_directory(i = :chroot) ⇒ Object
#
backup_into_the_default_chroot_directory (chroot tag)
#
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1068 def backup_into_the_default_chroot_directory( i = :chroot ) e e "#{rev}Setting the target to #{sdir(i)} next." e set_target_mountpoint(i) # Set to the above Chroot target. We could also use :chroot. set_main_target( "#{main_target?.dup}#{home_dir_of_user_x?.dup}" ) # ======================================================================= # # Must copy the autogenerated directory first: # ======================================================================= # try_to_backup_the_autogenerated_directory all_important_directories?.each {|this_directory| tab_title 'Now backing up the '+this_directory+' directory ...' new_target = main_target?+File.basename(this_directory) mkdir(new_target) cpr(this_directory, main_target?) } end |
#backup_the_audio_directory(i = DIRECTORY_CONTAINING_ALL_SONGS, copy_only_missing_audio_files = true) ⇒ Object Also known as: try_to_backup_the_audio_directory, backup_audio_directory
#
backup_the_audio_directory (audio tag, audio dir tag)
This method can be used to backup my audio directory, which normally resides at “/home/x/songs/”.
Two arguments can be supplied to this method:
(1) The first argument specifies which directory is used as the
input directory, where the songs that are to be copied
should reside.
(2) If the second argument is true then only those audio files
that are missing will be copied.
#
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1256 def backup_the_audio_directory( i = DIRECTORY_CONTAINING_ALL_SONGS, copy_only_missing_audio_files = true ) if File.directory? i copied_n_files = 0 print rev cliner new_target = mountpoint?.squeeze('/') opne "Now trying to backup the Audio directory "\ "at `#{sdir(i)}`." colourized_target = sdir("#{new_target}#{File.basename(i)}/") opne "The target for this will be at "\ "`#{colourized_target}`." n_gigabytes = BackupParadise.size_in_gigabytes?(i).to_s opne 'This directory has a total of '+ sfancy(n_files_in?(i).to_s)+rev+ ' entries '\ '(Total size: '+n_gigabytes+' GB).' cliner unless File.directory? "#{new_target}#{File.basename(i)}/" opnn; verbose_create_a_directory_at_this_position( "#{new_target}#{File.basename(i)}/" ) end tab_title('Backing up the main audio directory.') # ===================================================================== # # Else we will copy only the audio files that are missing. In order # to do so we have to obtain all audio-files - we will simply # pick all files, anyway. We will keep these entries sorted, too. # ===================================================================== # these_audio_files_may_be_copied = Dir[ rds("#{i.delete('*')}/*") ].sort if copy_only_missing_audio_files these_audio_files_may_be_copied.each {|this_file| totally_new_target = "#{new_target}#{File.basename(i)}/#{File.basename(this_file)}" # ================================================================= # # We check whether the target-file exists. Only if it does not # exist will it be copied. # ================================================================= # unless File.exist? totally_new_target copied_n_files += 1 # =============================================================== # # Pad the display. # =============================================================== # padded_file = this_file.ljust(40) padded_target = totally_new_target.ljust(40) e "Copying `#{sfile(padded_file)}` to" e " `#{sfile(padded_target)}`." copy_this_file(this_file, totally_new_target) end } # =================================================================== # # Ok, now, if we removed a file from /Depot/Audio, then the Audio/ # directory at the mounted USB device may still have such a file. # So we will warn the user about this. # =================================================================== # target = "#{new_target}#{File.basename(i)}/" # This will be something like "/Mount/USB1/songs/" unless these_audio_files_may_be_copied.size == Dir["#{target}*"].size opne 'It seems as if we have an unequal amount of Audio files in ' opne 'the two directories.' opne 'This usually means that the original directory '+ sdir(i)+' has some files' opne 'deleted, but the target directory at '+sdir(target)+' does not.' opne rev+'The old directory has '+simp(i.size.to_s)+rev+' entries.' end else cpr(i, new_target) end _ = "#{new_target}#{File.basename(i)}/" if copied_n_files == 0 opne "No file was copied into the directory #{sdir(_)}." opne 'This may indicate that the target audio-directory already' opne 'contains all necessary audio-files.' else opne "Finished backing up the directory "\ "#{sdir(i.delete('*'))} into "\ "#{sdir(_)}." end default_tab_title else can_not_backup_this_directory_as_it_does_not_exist(i) end end |
#backup_the_audio_directory_then_exit ⇒ Object
#
backup_the_audio_directory_then_exit
Backup the audio directory, then exit the program.
#
547 548 549 550 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 547 def backup_the_audio_directory_then_exit backup_the_audio_directory exit_program end |
#backup_the_books_directory(target_directory = BOOKS_DIRECTORY) ⇒ Object Also known as: backup_only_books_directory, backup_books_directory
#
backup_the_books_directory (data tag)
This method will backup the BOOKS directory, e. g. the one that is at “/home/x/books/” on my home system.
#
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1130 def backup_the_books_directory( target_directory = BOOKS_DIRECTORY ) target_directory = ensure_trailing_backslash_for(target_directory) if File.directory? target_directory tab_title('Backing up the '+target_directory+' directory.') cliner e 'Now backing up the books/ directory from '+ sfancy(target_directory)+' into '+ sfile(main_target?+File.basename(target_directory)) cliner report_total_size_of(target_directory) unless File.directory? backup_to_this_target?+File.basename(target_directory) opnn; verbose_create_a_directory_at_this_position( backup_to_this_target?+File.basename(target_directory), 0755 ) end cpr( target_directory, backup_to_this_target? ) rename_tab('.') else can_not_backup_this_directory_as_it_does_not_exist(target_directory) end end |
#backup_the_data_directory(target_directory = DATA_DIRECTORY) ⇒ Object Also known as: backup_only_data_directory, backup_data_directory
#
backup_the_data_directory (data tag)
This method will backup the DATA directory, e. g. the one that is at “/home/x/data/” on my home system.
#
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 942 def backup_the_data_directory( target_directory = DATA_DIRECTORY ) if File.directory? target_directory mountpoint_target = main_target?+File.basename(target_directory) print rev cliner e "#{rev}Now backing up the DATA directory from "\ "#{sfancy(target_directory)} into "\ "#{sfile(mountpoint_target)}." cliner report_total_size_of(target_directory) unless File.directory? mountpoint_target create_directory(mountpoint_target, 0755) end mkdir(backup_to_this_target?+File.basename(target_directory)) cpr( target_directory, backup_to_this_target? ) else can_not_backup_this_directory_as_it_does_not_exist(target_directory) end end |
#backup_the_data_directory_then_exit ⇒ Object Also known as: backup_data_directory_then_exit
#
backup_the_data_directory_then_exit
Backup only Data directory.
#
931 932 933 934 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 931 def backup_the_data_directory_then_exit backup_data_directory exit_program end |
#backup_the_programs_directory(target_directory = PROGRAMS_DIRECTORY) ⇒ Object
#
backup_the_programs_directory
This method can be used to backup the /Programs directory.
#
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 736 def backup_the_programs_directory( target_directory = PROGRAMS_DIRECTORY ) if File.directory? target_directory cliner e 'Now backing up the Programs/ directory from '+ sfancy(target_directory)+' into '+ sfile(main_target?+File.basename(target_directory)) cliner report_total_size_of(target_directory) if target_hdd_does_not_have_enough_space_left? opne "We have to skip backing up #{sdir(target_directory)}" opne 'as it does not have enough space left (Threshold: '+ MINIMAL_FILESIZE+' bytes)' else backup_this_directory_if_it_exists( target_directory, :default, :do_not_continue ) end else can_not_backup_this_directory_as_it_does_not_exist(target_directory) end end |
#backup_the_source_directory(target_directory = SOURCE_DIRECTORY) ⇒ Object
#
backup_src_directory (src tag)
This method will backup the SRC/ directory, aka “/home/x/src/”. It is evidently geared towards the system at my home setup.
To invoke this method from the commandline, try:
rbackup --src-dir
#
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1102 def backup_the_source_directory( target_directory = SOURCE_DIRECTORY ) target_directory = ensure_trailing_backslash_for(target_directory) if File.directory? target_directory tab_title('Backing up the '+target_directory+' directory.') cliner e 'Now backing up the '+sdir('src/')+' directory from '+ sfancy(target_directory)+' into '+ sfile(main_target?+File.basename(target_directory)) cliner report_total_size_of(target_directory) mkdir(backup_to_this_target?+File.basename(target_directory)) cpr( target_directory, backup_to_this_target? ) else can_not_backup_this_directory_as_it_does_not_exist(target_directory) end end |
#backup_the_studium_directory(target_directory = STUDIUM_DIRECTORY) ⇒ Object
#
backup_the_studium_directory
#
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 980 def backup_the_studium_directory( target_directory = STUDIUM_DIRECTORY ) target_directory = ensure_trailing_backslash_for(target_directory) if File.directory? target_directory tab_title('Backing up the '+target_directory+' directory.') cliner e 'Now backing up the studium/ directory from '+ sfancy(target_directory)+' into '+ sfile(main_target?+File.basename(target_directory)) cliner report_total_size_of(target_directory) mkdir(backup_to_this_target?+File.basename(target_directory)) cpr( target_directory, backup_to_this_target? ) else can_not_backup_this_directory_as_it_does_not_exist(target_directory) end end |
#backup_the_system_directory(target_directory = SYSTEM_SETTINGS_DIRECTORY) ⇒ Object Also known as: backup_system_directory
#
backup_the_system_directory
This method can be used to backup the “/System/Settings/” directory, as it may be found in GoboLinux.
#
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 897 def backup_the_system_directory( target_directory = SYSTEM_SETTINGS_DIRECTORY ) if File.directory? target_directory cliner e rev+'Now backing up the system-settings directory from '+ sfancy(target_directory)+ rev+' into '+ sfile( main_target?+File.basename(target_directory) ) cliner report_total_size_of(target_directory) cpr( target_directory, backup_to_this_target? ) else can_not_backup_this_directory_as_it_does_not_exist(target_directory) end end |
#backup_the_video_directory(target_directory = VIDEO_DIRECTORY) ⇒ Object
#
backup_the_video_directory
#
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1005 def backup_the_video_directory( target_directory = VIDEO_DIRECTORY ) target_directory = ensure_trailing_backslash_for(target_directory) if File.directory? target_directory cliner e 'Now backing up the Video directory from '+ sfancy(target_directory)+' into '+ sfile(main_target?+File.basename(target_directory)) cliner tab_title('Backing up the directory '+target_directory+' next.') report_total_size_of(target_directory) set_backup_to_this_target(target_base_directory?) mkdir( target_base_directory?+File.basename(target_directory) ) cpr( target_directory, target_base_directory? ) default_tab_title else can_not_backup_this_directory_as_it_does_not_exist(target_directory) end end |
#backup_this_directory(i, copy_to_this_target_directory = nil, shall_we_sync = true) ⇒ Object
#
backup_this_directory
This method will quickly backup a given directory.
The second argument will be the target-directory onto which we will copy our files.
#
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 861 def backup_this_directory( i, copy_to_this_target_directory = nil, shall_we_sync = true ) case shall_we_sync when :do_not_sync shall_we_sync = false end case copy_to_this_target_directory when nil, :default copy_to_this_target_directory = return_default_target_directory_from_this_input(i) end unless File.directory? copy_to_this_target_directory mkdir(copy_to_this_target_directory) end cd copy_to_this_target_directory opne rev+'Now copying '+sdir(i)+ rev+' to '+sdir(copy_to_this_target_directory)+ rev+'.' if File.directory?(i) i << '*' end cpr( i, copy_to_this_target_directory ) do_sync if shall_we_sync end |
#backup_to_this_target? ⇒ Boolean
#
backup_to_this_target?
#
922 923 924 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 922 def backup_to_this_target? @backup_to_this_target end |
#backup_which_directories? ⇒ Boolean
#
backup_which_directories?
#
225 226 227 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 225 def backup_which_directories? @internal_hash[:backup_these_directories] end |
#can_not_backup_this_directory_as_it_does_not_exist(i) ⇒ Object
#
can_not_backup_this_directory_as_it_does_not_exist
#
389 390 391 392 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 389 def can_not_backup_this_directory_as_it_does_not_exist(i) opne "Can not backup the directory at #{sdir(i)}" opne 'as it does not exist.' end |
#commandline_arguments? ⇒ Boolean
#
commandline_arguments?
#
287 288 289 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 287 def commandline_arguments? @commandline_arguments end |
#consider_creating_a_log_file(n_seconds) ⇒ Object
#
consider_creating_a_log_file
This method will create a .log file.
It accepts an argument, which should be an Integer or Float, denoting, in seconds, how long it took to make a backup.
#
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1222 def consider_creating_a_log_file( n_seconds ) if File.directory? '/Depot/Temp/' n_minutes = (n_seconds.to_f / 60).round(1).to_s # ===================================================================== # # Make the seconds a bit prettier next, via trailing '0'. # ===================================================================== # n_seconds = '%.3f' % n_seconds what = "#{return_full_date}: Backing up the system took #{n_seconds} "\ "seconds (#{n_minutes} minutes).\n" into = FILE_BACKUP_LOG opne "Storing the time it took to backup "\ "into the file `#{sfile(into)}`." append_what_into(what, into) end end |
#consider_removing_all_but_one_log_file ⇒ Object
#
consider_removing_all_but_one_log_file
#
681 682 683 684 685 686 687 688 689 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 681 def consider_removing_all_but_one_log_file log_files = return_all_log_files if log_files.size > 1 opne 'More than one log file has been found. We will delete' opne 'all but one next.' log_files.pop delete_files(log_files, :be_verbose) end end |
#consider_renaming_all_old_last_backup_directories ⇒ Object
#
consider_renaming_all_old_last_backup_directories
This will rename all “last_directory*” directory entries to their corresponding equivalent without the leading ‘last_’ string.
#
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 434 def consider_renaming_all_old_last_backup_directories # ======================================================================= # # First grab all possible entries, and check that these are all existing # directories. If there is at the least one entry we will continue to # operate on it. # ======================================================================= # all_possible_entries = Dir["#{mount_target?}last_backup-*"].select {|entry| File.directory?(entry) } if all_possible_entries.size > 0 # ===================================================================== # # Batch-rename these directories in that case: # ===================================================================== # all_possible_entries.each {|this_directory| new_name_of_the_new_target_directory = this_directory.sub(/^last_/,'') opne "#{rev}Now renaming `#{sdir(this_directory)}#{rev}` "\ "to `#{sdir(new_name_of_the_new_target_directory)}#{rev}`." rename(this_directory, new_name_of_the_new_target_directory) } end end |
#create_a_symlink_pointing_to_that_directory_that_was_just_created ⇒ Object Also known as: create_symlink_to_last_backup_directory
#
create_a_symlink_pointing_to_that_directory_that_was_just_created
This method will create a symlink to the last_backup/ directory.
This is synonymous to the following ruby code:
File.symlink('last_backup-13.08.2018-22:12:26/','last_backup')
#
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 812 def create_a_symlink_pointing_to_that_directory_that_was_just_created cd_to_the_mounted_device create_a_symlink_here = "#{backup_to_this_directory?}last_backup" from_this_target = File.basename(@internal_hash[:last_backup_directory]) from_this_target.chop! if from_this_target.end_with? '/' # ========================================================================= # # First, delete the old symlink if it exists. The method delete_symlink() # will do that check for us. # ========================================================================= # delete_symlink(create_a_symlink_here) # ========================================================================= # # The next action can fail on e. g. vfat filesystems, with the error # being Errno::EPERM. Hence we must rescue here. # ========================================================================= # begin do_symlink(from_this_target, create_a_symlink_here) if File.exist? create_a_symlink_here points_towards = File.readlink(create_a_symlink_here) opne rev+'Next setting a symlink at `'+sfancy(create_a_symlink_here)+ rev+'` pointing' opne "#{rev}towards `#{sfile(points_towards)}#{rev}`." else opne no_file_exists_at(create_a_symlink_here) end rescue Errno::EPERM end end |
#create_file_keeping_track_of_when_the_last_backup_happened(use_this_as_timestamp = use_this_as_timestamp? ) ⇒ Object Also known as: store_when_was_the_last_backup
#
create_file_keeping_track_of_when_the_last_backup_happened
This method will store date-information into a file, when the last backup happened.
It is normally found in a place such as:
/home/x/data/LAST_BACKUP.md
Since Dec 2012, we will also append the date to the name of said file.
#
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 577 def create_file_keeping_track_of_when_the_last_backup_happened( = ) base_target = "#{data_directory?}LAST_BACKUP" target = "#{base_target}_#{date?}.md" # Append the date here. e N+'Storing '+sfile()+rev+ ' into '+sfile(target)+rev+' to note' e "#{rev}down when the last backup was performed." write_what_into(, target) # ======================================================================= # # Next, obtain an array with potential similar names. We will have # to delete stray entries so as to not clutter our original home # directory there. # ======================================================================= # array_all_last_backup_files = Dir["#{base_target}*"] if array_all_last_backup_files.size > 1 array_all_last_backup_files = array_all_last_backup_files.sort_by {|d| d.split('.').reverse } # Keep it sorted. e N+'We found more than one entry in '+ sdir(File.dirname(base_target)+'/')+ rev+ ', thus removing' e "#{rev}the extra-entries next." array_all_last_backup_files[0..-2].each {|my_file| e "#{rev}Removing `#{sfile(my_file)}#{rev}` next." remove_file(my_file) } end end |
#create_the_directory_containing_the_last_backup ⇒ Object
#
create_the_directory_containing_the_last_backup
#
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 786 def create_the_directory_containing_the_last_backup target = "#{main_target?}backup-#{}" # ======================================================================= # # Next, create the last_backup directory: # ======================================================================= # begin mkdir(target, 0755) rescue Errno::EINVAL target.tr!(':','_') mkdir(target, 0755) end @internal_hash[:last_backup_directory] = rds(target+'/') opne "Creating a directory at "\ "`#{sdir(@internal_hash[:last_backup_directory])}`." end |
#create_the_log_last_backup_file ⇒ Object Also known as: create_log_file
#
create_the_log_last_backup_file (log tag)
We also have to remove all prior log files should they exist.
#
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1185 def create_the_log_last_backup_file _ = return_all_log_files target = main_target?+'log_last_backup_'+ what = dd_mm_yyyy opne "Keeping a backup file (a log) at" opne "`#{sfile(target)}`." write_what_into(what, target) unless _.empty? # ===================================================================== # # Remove all old log files next. # ===================================================================== # remove_these_files(_) end end |
#date? ⇒ Boolean
#
349 350 351 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 349 def date? @internal_hash[:date] end |
#default_tab_title ⇒ Object
#
default_tab_title
#
218 219 220 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 218 def default_tab_title tab_title('Backup is complete!') end |
#determine_end_time ⇒ Object
#
determine_end_time
#
727 728 729 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 727 def determine_end_time @internal_hash[:array_store_times] << Time.now end |
#determine_the_current_timestamp ⇒ Object
#
determine_the_current_timestamp
#
336 337 338 339 340 341 342 343 344 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 336 def if @internal_hash[:simplify_the_directory_layout] @internal_hash[:use_this_as_timestamp] = "#{date?}-#{current_time.tr(':','_')}" else @internal_hash[:use_this_as_timestamp] = "#{date?}-#{current_time}" end end |
#determine_the_starting_time ⇒ Object Also known as: determine_starting_time
#
determine_the_starting_time
#
720 721 722 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 720 def determine_the_starting_time @internal_hash[:array_store_times] << Time.now end |
#determine_the_target_mountpoint(i = '/Mount/USB1/') ⇒ Object
#
determine_the_target_mountpoint
This method will determine the target base mountpoint that is to be used.
#
777 778 779 780 781 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 777 def determine_the_target_mountpoint( i = '/Mount/USB1/' ) BackupParadise.target_mountpoint = i end |
#determine_where_to_backup_to_exactly(i = mountpoint? ) ⇒ Object
#
determine_where_to_backup_to_exactly
This is automatically called whenever set_mountpoint() is called.
#
513 514 515 516 517 518 519 520 521 522 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 513 def determine_where_to_backup_to_exactly( i = mountpoint? ) backup_to_this_target = i @backup_to_this_target = backup_to_this_target.dup @backup_to_this_target << "/backup-#{return_current_date_and_time}/" @backup_to_this_target = @backup_to_this_target.squeeze('/') @backup_to_this_target.tr!(':','_') if simplify_the_directory_layout? set_last_backup_directory(@backup_to_this_target) end |
#determine_whether_the_target_harddisc_is_a_ntfs_system ⇒ Object
#
determine_whether_the_target_harddisc_is_a_ntfs_system
#
301 302 303 304 305 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 301 def determine_whether_the_target_harddisc_is_a_ntfs_system if is_target_harddisc_a_ntfs_system? do_use_simplified_directory end end |
#do_not_perform_the_regular_backup_routine ⇒ Object
#
do_not_perform_the_regular_backup_routine
#
1162 1163 1164 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1162 def do_not_perform_the_regular_backup_routine @internal_hash[:perform_backup] = false end |
#do_perform_the_backup_tasks ⇒ Object Also known as: start_backup, backup_everything, do_backup
#
do_perform_the_backup_tasks (all tag)
This method is the main powerhouse of this class. It connects all the various steps together, one after the other.
#
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1762 def do_perform_the_backup_tasks backup_to_this_target = backup_to_this_target? determine_the_starting_time create_file_keeping_track_of_when_the_last_backup_happened determine_whether_the_target_harddisc_is_a_ntfs_system if is_on_roebe? and # ===================================================================== # # So in this case we want to backup to a local harddisc, such # as /Mount/HDD1. In this case we must find out whether the # harddisc is already mounted or not. If not then we will # mount it here. # ===================================================================== # if is_the_harddisc_properly_mounted? # In this case assume all is already mounted. # =================================================================== # # All is fine in this case - we do not have to do anything. At the # least we assume this is the case. # =================================================================== # else # =================================================================== # # Here we must mount it still. For now this uses a hardcoded approach. # =================================================================== # target = mountpoint? e "Mounting #{steelblue('/dev/sdb3')}#{rev} "\ "towards #{steelblue(target)}#{rev}." esystem('mount /dev/sdb3 '+target) end end tab_title 'Backing up some data next, onto '+backup_to_this_target.to_s+' ...' cd last_backup_directory? # ======================================================================= # # Remove some log-files next, if necessary. # ======================================================================= # consider_removing_all_but_one_log_file # ======================================================================= # # The next method will rename entries such as: # # "last_backup-13.10.2018-21:07:20/" # # to # # "backup-13.10.2018-21:07:20/" # # specifically. # # This is necessary so that we can only have one such directory # name, after we are done with this method here. # ======================================================================= # consider_renaming_all_old_last_backup_directories # ======================================================================= # # We will also create a log file, to denote when we started to # do this current backup-operation. # ======================================================================= # create_the_log_last_backup_file create_the_directory_containing_the_last_backup create_a_symlink_pointing_to_that_directory_that_was_just_created # ======================================================================= # # === Back up the AUTOGENERATED directory # # We will next attempt to backup the directory at /AUTOGENERATED/. # This must come before we create a new directory at the mounted # USB device, simply because we may not copy anything at all, # or some error may happen that causes an interrupt. # ======================================================================= # try_to_backup_the_autogenerated_directory # ======================================================================= # # === Back up the audio directory as well # ======================================================================= # try_to_backup_the_audio_directory unless File.directory? backup_to_this_target FileUtils.mkdir_p(backup_to_this_target) end # ======================================================================= # # Next, iterate over the directories that we wish to backup. # ======================================================================= # backup_which_directories?.each {|this_directory| this_directory = ensure_trailing_backslash_for(this_directory) tab_title("Backing up #{this_directory}.") this_directory = this_directory.dup if this_directory.frozen? # ===================================================================== # # Ensure that we have a trailing '/' character here. # ===================================================================== # this_directory << '/' unless this_directory.end_with?('/') e "#{rev}Now backing up the directory #{sdir(this_directory)}"+ ' onto '+ steelblue( backup_to_this_target+ File.basename(this_directory) )+'.' cpr(this_directory, backup_to_this_target) } # ======================================================================= # # === Delete all symlinks from the target, if we are using a # NTFS system as our target-device # ======================================================================= # if is_target_harddisc_a_ntfs_system? all_symlinks = return_all_symlinks_from_this_directory(backup_to_this_target) unless all_symlinks.empty? e "#{rev}As we are using a NTFS system, we will next remove all "+ "#{royalblue(all_symlinks.size.to_s)} symlinks" e "#{rev}found at the following target: #{sdir(backup_to_this_target)}" e e steelblue('Specifically:') e e all_symlinks.join(', ').strip.chop e end all_symlinks.each {|this_symlink| remove_this_symlink(this_symlink) } end popup_notification(:backup_complete) if show_popup_notification? do_sync # Synchronize the USB devices here, before we determine the end time. determine_end_time report_time_difference try_to_unmount_the_device tab_title('Backup is complete!') # or: tab_title '' end |
#do_show_popup ⇒ Object Also known as: show_popup
#
do_show_popup
#
504 505 506 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 504 def do_show_popup @internal_hash[:show_popup_notification] = true end |
#do_sync ⇒ Object Also known as: synchronize
#
do_sync
The do_sync() method, also aliased towards synchronize(), will sync the data onto USB items, by using the sync command.
#
846 847 848 849 850 851 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 846 def do_sync opne 'Starting to '+steelblue('sync data')+' ...' system 'sync' # Be silent since May 2014. opne "> Syncing finished. (At: "\ "#{rosybrown(return_current_date_and_time.to_s)})" end |
#do_use_simplified_directory ⇒ Object
#
do_use_simplified_directory
The old code used to be like this:
set_last_backup_directory(mount_point?+'last_backup')
#
560 561 562 563 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 560 def do_use_simplified_directory @internal_hash[:simplify_the_directory_layout] = true # Must sync it back again. end |
#ensure_trailing_backslash_for(i) ⇒ Object
#
ensure_trailing_backslash_for
#
971 972 973 974 975 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 971 def ensure_trailing_backslash_for(i) i = i.dup i << '/' unless i.end_with? '/' return i end |
#first_argument? ⇒ Boolean Also known as: first?
#
first_argument?
#
294 295 296 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 294 def first_argument? @commandline_arguments.first end |
#is_target_harddisc_a_ntfs_system? ⇒ Boolean
#
is_target_harddisc_a_ntfs_system?
This method will return a boolean - true or false.
It will return true if the target harddisc is a NTFS system, and false otherwise.
#
1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1893 def is_target_harddisc_a_ntfs_system? return_value = false _ = '/Mount' if mount_target?.include? _ # ===================================================================== # # Next, determine what is mounted. # ===================================================================== # these_may_be_mounted = `df -T -ah`.split(N).select {|line| line.include? _ } if these_may_be_mounted and these_may_be_mounted.first and these_may_be_mounted.first.include?('fuseblk') # This may mean a NTFS system. # =================================================================== # # However had, in August of 2023 it was realiased that multiple # filesystems may be mounted, so the above assumption was a bit # too simple. # =================================================================== # return_value = true unless end end return return_value end |
#is_the_harddisc_properly_mounted? ⇒ Boolean
#
is_the_harddisc_properly_mounted?
#
1744 1745 1746 1747 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1744 def is_the_harddisc_properly_mounted? result_of_df_T = `df -T` return result_of_df_T.include? '/Mount/HDD' end |
#last_backup_directory? ⇒ Boolean
#
last_backup_directory?
#
1203 1204 1205 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1203 def last_backup_directory? @internal_hash[:last_backup_directory] end |
#menu(i = commandline_arguments? ) ⇒ Object
#
menu (menu tag)
#
1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1398 def ( i = commandline_arguments? ) return if i.nil? # ======================================================================= # # === Handle Hashes # # Note that this is the default entry point. # # An example for how this may be used is given next: # # BackupParadise::Actions.backup( # backup_these_directories: i, # where_to: to # ) # # ======================================================================= # if i.is_a? Hash # ===================================================================== # # === :backup_to_this_target # # The next check must come early, on top. # ===================================================================== # # ===================================================================== # # === :where_to # ===================================================================== # if i.has_key? :where_to set_backup_to_this_target(i[:where_to]) elsif i.has_key? :backup_to_this_target set_backup_to_this_target(i[:backup_to_this_target]) end # ===================================================================== # # === :commandline_arguments # ===================================================================== # if i.has_key? :commandline_arguments (i[:commandline_arguments]) # ===================================================================== # # === :backup_these_directories # ===================================================================== # elsif i.has_key? :backup_these_directories (i[:backup_these_directories]) end # ======================================================================= # # === Handle Arrays # ======================================================================= # elsif i.is_a? Array i.each {|entry| (entry) } else case i # case tag # ===================================================================== # # === rbackup --audio-dir # # This entry point can be used to specifically backup the # audio-directory - that is, the local directory that # contains all songs. # # Usage example: # # rbackup --audio-dir # # A more advanced invocation example is: # # rbackup --backup-to=/opt/ --audio-dir # # ===================================================================== # when /^-?-?audio(-| |_)?dir$/i, /^-?-?audio$/i, /^-?-?aud$/i, /^-?-?audi$/i, /^-?-?aonly$/i, /^-?-?audio(-| |_)?only$/i determine_whether_the_target_harddisc_is_a_ntfs_system backup_the_audio_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --libui # ===================================================================== # when /^-?-?lib-?ui$/i, /^-?-?gui2$/i require 'backup_paradise/gui/libui/backup_for_ingrid/backup_for_ingrid.rb' BackupParadise::GUI::LibUI::BackupForIngrid.new exit # ===================================================================== # # === rbackup --gui # # Alternatively use rbackup --gtk3. # ===================================================================== # when /^-?-?gui$/i, /^-?-?gtk3$/i, /^-?-?gtk$/i, /^-?-?gui1$/i start_the_gtk3_bindings do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --version? # ===================================================================== # when /^-?-?version\??$/i e BackupParadise::VERSION do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --are-we-on-windows? # ===================================================================== # when /^-?-?are(-| |_)?we(-| |_)?on(-| |_)?windows\??$/i e rev+'Are we on windows? '+ steelblue(are_we_on_windows?.to_s) do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --help # # The user can use this entry point to obtain helpful information in # how to use this class, on the commandline. # ===================================================================== # when /help/i, /^-?-?show(-| |_)?help$/i, 'hel', 'he','h','?','*' show_help do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --video-dir # ===================================================================== # when /^-?-?video(-| |_)?dir$/i, /^-?-?video(-| |_)?directory$/i, /^-?-?video$/i backup_the_video_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --books # # This entry point allows the user to backup the /home/x/books/ # directory. # ===================================================================== # when /^-?-?books$/i, /^-?-?books(-| |_)?directory$/i backup_the_books_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --source-dir # === rbackup --source-directory # === rbackup --source # === rbackup --src-dir # === rbackup --src # # This entry point allows the user to backup the /home/x/src/ # directory. # ===================================================================== # when /^-?-?source(-| |_)?dir$/i, /^-?-?source(-| |_)?directory$/i, /^-?-?source$/i, /^-?-?src(-| |_)?dir$/i, /^-?-?src$/i backup_the_source_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === Backup all relevant entries to the chroot-directory # # This entry point is mostly used for my local Chroot directory. We # will quickly backup the important files to that directory, which # then allows us to cd into a better chroot-environment. # # Invocation examples: # # rbackup --chroot # rbackup --to-chroot # # ===================================================================== # when /^-?-?chroot$/i, /^-?-?to(-| |_)?chroot$/i, /^-?-?into(-| |_)?chroot$/i backup_into_the_default_chroot_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --studium-dir # === rbackup --studium-directory # === rbackup --studium # # This entry point allows the user to backup the /home/x/studium/ # directory, by making use of the constant STUDIUM_DIRECTORY. # ===================================================================== # when /^-?-?studium(-| |_)?dir$/i, /^-?-?studium(-| |_)?directory$/i, /^-?-?studium$/i backup_the_studium_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --data-dir # ===================================================================== # when /^-?-?data(-| |_)?dir$/i, /^-?-?data(-| |_)?directory$/i, /^-?-?data$/i, /^-?-?ONLY(-| |_)?DATA$/i, /^-?-?DATA(-| |_)?ONLY$/i, /^-?-?donly$/i backup_the_data_directory_then_exit # ===================================================================== # # === rbackup --system-dir # ===================================================================== # when /^-?-?system(-| |_)?dir$/i, /^-?-?system(-| |_)?directory$/i, /^-?-?system$/i backup_the_system_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --programs-dir # # This entry point can be used to backup /home/Programs/ specifically. # ===================================================================== # when /^-?-?programs(-| |_)?dir$/i, /^-?-?programs$/i backup_the_programs_directory do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup default # ===================================================================== # when 'default' # Default entry point is for /Mount/USB1 aka :usb1. set_target_mountpoint(:usb1) # ===================================================================== # # === rbackup --mountpoints # ===================================================================== # when /^-?-?mountpoints/ show_available_mountpoints_then_exit # ===================================================================== # # === rbackup --logfile # ===================================================================== # when /^-?-?logfile\??$/i show_the_logfile do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --show-file-size-of-popular_directories # === rbackup --overview # ===================================================================== # when /^-?-?show(-| |_)?file(-| |_)?size(-| |_)?of(-| |_)?popular(-| |_)?directories$/i, /^-?-?overview$/i use_this_array = [ return_the_songs_directory, PROGRAMS_DIRECTORY, VIDEO_DIRECTORY, STUDIUM_DIRECTORY, DATA_DIRECTORY, SOURCE_DIRECTORY ].map {|entry| return_this_absolute_directory(entry) } use_this_array.each {|this_entry| report_file_size_of(this_entry) } do_not_perform_the_regular_backup_routine # ===================================================================== # # === rbackup --use-this-as-target-for-backup=/opt/ # === rbackup --use-this-as-target=/opt/ # === rbackup --backup-to=/opt/ # # This entry point allows the user to specify another target to # be used from the commandline. # ===================================================================== # when /^-?-?backup(-| |_)?to=(.+)$/i, /^-?-?use(-| |_)?this(-| |_)?as(-| |_)?target=(.+)$/i, /^-?-?use(-| |_)?this(-| |_)?as(-| |_)?target(-| |_)?for(-| |_)?backup=(.+)$/i _ = $2.to_s.dup _ = $4.to_s.dup if $4 _ = $6.to_s.dup if $6 opne 'The target device will be at '+sfancy(_)+'.' set_target_device(_) # ===================================================================== # # === Use a shorter name for the backup-directory # # This entry point has been created to allow simpler backup onto # NTFS devices. I ran into a problem with a too-long, and special # name for a directory. # # Usage example: # # rbackup --use-shorter-name # rbackup tousb1 --use-shorter-name # # ===================================================================== # when /^-?-?use(-| |_)?shorter(-| |_)?name$/i, /^-?-?windows$/i, /^-?-?sane-symlink$/i do_use_simplified_directory # ===================================================================== # # === rbackup --pwd # ===================================================================== # when /^-?-?pwd$/i current_directory = (Dir.pwd+'/').squeeze('/') set_target_mountpoint(current_directory) # ===================================================================== # # === rbackup --autogenerated # ===================================================================== # when /^-?-?autogen$/, 'agen', 'autog', /^-?-?autogenerated$/i determine_whether_the_target_harddisc_is_a_ntfs_system try_to_backup_the_autogenerated_directory do_not_perform_the_regular_backup_routine else # else tag # =================================================================== # # === Backup an existing directory # # This entry point allows us to quickly backup an existing # directory. # # Usage example: # # rbackup /home/x/data/rpg/ # # =================================================================== # if File.directory?(i) i = File.absolute_path(i) i << '/' unless i.end_with? '/' new_target = mountpoint?.squeeze('/') cpr(i, new_target) do_not_perform_the_regular_backup_routine # =================================================================== # # === Backup individual .h files quickly # # This is a short circuit action here - we just backup an existing # .h file quickly. # # Invocation example: # # rbackup /usr/include/xvid.h # # =================================================================== # elsif File.exist?(i) and i.end_with?('.h') base_directory = '/BACKUP/include/' verbose_create_a_directory_at_this_position(base_directory) target = "#{base_directory}#{File.basename(i)}" opne "#{rev}Backing up towards `#{sfile(target)}#{rev}` (a mere copy operation)." copy_file(i, target) do_not_perform_the_regular_backup_routine else if i and i.start_with?('--') e "Option #{i} was not found. Exiting now." exit end end end end end |
#mountpoint? ⇒ Boolean Also known as: mounted_at?, target_base_directory?
#
mountpoint?
#
527 528 529 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 527 def mountpoint? @internal_hash[:mountpoint] end |
#opnn(i = NAMESPACE) ⇒ Object
#
opnn
#
535 536 537 538 539 540 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 535 def opnn(i = NAMESPACE) if i.is_a? String i = { namespace: i } end super(i) end |
#perform_the_regular_backup_routine? ⇒ Boolean
#
perform_the_regular_backup_routine?
#
1169 1170 1171 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1169 def perform_the_regular_backup_routine? @internal_hash[:perform_backup] end |
#popup_notification(what = :backup_complete) ⇒ Object
#
popup_notification
Use this method to send a graphical popup to the user. Only invoke it when we set @show_popup_notification to true.
#
708 709 710 711 712 713 714 715 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 708 def popup_notification( what = :backup_complete ) case what when :backup_complete esystem 'xmessage -center Backup finished!' end end |
#report_time_difference ⇒ Object
#
report_time_difference
This method will report to the user how long it took this class to backup the system, e. g. 30 minutes or something like that.
#
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 649 def report_time_difference if @internal_hash[:array_store_times].size > 1 start_time = @internal_hash[:array_store_times][-2] end_time = @internal_hash[:array_store_times].last time_difference = end_time - start_time # This will result in a Float. if time_difference.respond_to? :round time_difference = time_difference.round(3) end n_minutes = (time_difference.to_f / 60.0).round(2).to_s opne "#{tomato('Time required')} #{rev}for this backup-operation: "\ "#{sfancy(time_difference.to_s)}"\ " #{rev}seconds (#{royalblue(n_minutes)} #{rev}minutes)." consider_creating_a_log_file(time_difference) end end |
#report_todays_date ⇒ Object
#
report_todays_date
#
1176 1177 1178 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1176 def report_todays_date e "Today is the #{sfancy(date?)}." end |
#reset ⇒ Object
#
reset (reset tag)
#
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 128 def reset super() # ======================================================================= # # === @internal_hash # ======================================================================= # @internal_hash = {} # ======================================================================= # # === :mountpoint # ======================================================================= # @internal_hash[:mountpoint] = nil # ======================================================================= # # === :simplify_the_directory_layout # # If the following variable is set to true then this means that the # target directory will be slightly simplified. There will not be # any ':' characters; these will become '_' characters. # # This was necessary because windows NTFS seems to struggle with # ':' characters. # ======================================================================= # @internal_hash[:simplify_the_directory_layout] = true # ======================================================================= # # === :perform_backup # # The next variable determines whether we will perform a backup # job or not. By default this will be false - it will be set # to true through the menu() interface, via its else clause. # ======================================================================= # @internal_hash[:perform_backup] = true # ======================================================================= # # === :are_we_on_windows # # This can be used to overrule any other windows-specific checks. # ======================================================================= # @internal_hash[:are_we_on_windows] = nil # ======================================================================= # # === :date # ======================================================================= # @internal_hash[:date] = dd_mm_yyyy # ======================================================================= # # === :show_popup_notification # ======================================================================= # @internal_hash[:show_popup_notification] = BackupParadise.show_popup_notification? # ======================================================================= # # === :last_backup_directory # ======================================================================= # @internal_hash[:last_backup_directory] = nil # ======================================================================= # # === :array_store_times # # The next Array will keep track of how long it took to backup # the data. # ======================================================================= # @internal_hash[:array_store_times] = [] # ======================================================================= # # === :use_this_as_timestamp # # The next variable will keep the timestamp as-is. # # This may include ':' characters, which Windows NTFS does not seem # to like. Thus, since as of September 2020, a slightly simpler # variant is used here. # ======================================================================= # # ======================================================================= # # === :backup_these_directories # # Determine the directories that we wish to back up. # ======================================================================= # @internal_hash[:backup_these_directories] = all_important_directories? end |
#return_all_log_files(from_where = mounted_at? ) ⇒ Object
#
return_all_log_files
#
694 695 696 697 698 699 700 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 694 def return_all_log_files( from_where = mounted_at? ) Dir["#{from_where}log_last_backup_*"].select {|entry| File.file? entry # We only want files. } end |
#return_default_target_directory_from_this_input(i) ⇒ Object
#
return_default_target_directory_from_this_input
#
763 764 765 766 767 768 769 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 763 def return_default_target_directory_from_this_input(i) rds( main_target?+ File.basename(i)+ '/' ) end |
#return_the_assumed_mountpoint_from_this_input(i) ⇒ Object
#
return_the_assumed_mountpoint_from_this_input
#
310 311 312 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 310 def return_the_assumed_mountpoint_from_this_input(i) BackupParadise.return_the_assumed_mountpoint_from_this_input(i) end |
#return_the_songs_directory ⇒ Object
#
return_the_songs_directory
#
259 260 261 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 259 def return_the_songs_directory DIRECTORY_CONTAINING_ALL_SONGS end |
#return_this_absolute_directory(i) ⇒ Object
#
return_this_absolute_directory
#
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 232 def return_this_absolute_directory(i) i = case i # ======================================================================= # # === DATA_DIRECTORY # ======================================================================= # when 'DATA_DIRECTORY' DATA_DIRECTORY # ======================================================================= # # === SRC_DIRECTORY # ======================================================================= # when 'SRC_DIRECTORY', 'SOURCE_DIRECTORY' SOURCE_DIRECTORY # ======================================================================= # # === STUDIUM_DIRECTORY # ======================================================================= # when 'STUDIUM_DIRECTORY' STUDIUM_DIRECTORY else i end i end |
#run ⇒ Object
#
run (run tag)
#
1929 1930 1931 1932 1933 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1929 def run sanitize_the_commandline_arguments do_perform_the_backup_tasks if perform_the_regular_backup_routine? end |
#sanitize_the_commandline_arguments(hash = commandline_arguments? ) ⇒ Object
#
sanitize_the_commandline_arguments
This method will try to make sense of the passed arguments.
#
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 365 def sanitize_the_commandline_arguments( hash = commandline_arguments? ) copy = hash.dup # ======================================================================= # # === :commandline_arguments # ======================================================================= # if hash.is_a?(Hash) and hash.has_key?(:commandline_arguments) hash[:commandline_arguments].each {|entry| if BackupParadise.is_this_a_shortcut?(entry) copy[:backup_to_this_target] = BackupParadise.return_the_assumed_mountpoint_from_this_input(entry) copy[:commandline_arguments].reject! {|inner_entry| inner_entry == entry } end } set_commandline_arguments(copy) end end |
#set_commandline_arguments(i = ARGV) ⇒ Object
#
set_commandline_arguments
#
280 281 282 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 280 def set_commandline_arguments(i = ARGV) @commandline_arguments = i end |
#set_last_backup_directory(i) ⇒ Object
#
set_last_backup_directory
#
1210 1211 1212 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1210 def set_last_backup_directory(i) @internal_hash[:last_backup_directory] = i end |
#set_mountpoint(i) ⇒ Object Also known as: set_backup_to_this_target, set_target_mountpoint
#
set_mountpoint
#
317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 317 def set_mountpoint(i) i = i.dup if BackupParadise.is_this_a_shortcut?(i) i = return_the_assumed_mountpoint_from_this_input(i) end i = i.dup if i.frozen? i << '/' unless i.end_with? '/' @internal_hash[:mountpoint] = i # ======================================================================= # # Sync it back to the toplevel as well: # ======================================================================= # determine_the_target_mountpoint(@internal_hash[:mountpoint]) determine_where_to_backup_to_exactly end |
#show_available_mountpoints ⇒ Object
#
show_available_mountpoints
This helper-method can show the available mountpoints, at the least on a linux system.
To invoke this, try:
rbackup --mountpoints
#
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 619 def show_available_mountpoints begin require 'mountpoints' rescue LoadError; end if Mountpoints.is_any_mountpoint_available? opne 'The available (and mounted) USB devices are:' e Mountpoints[].each {|this_usb_device| e " #{sfancy(this_usb_device)}" } e else opne 'No external USB devices appear to be mounted.' end end |
#show_available_mountpoints_then_exit ⇒ Object
#
show_available_mountpoints_then_exit
#
638 639 640 641 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 638 def show_available_mountpoints_then_exit show_available_mountpoints exit_program end |
#show_backup_complete_message ⇒ Object Also known as: all_done, show_all_is_done_message, all_done_message
#
show_backup_complete_message
This variant will show that the backup has been complete on the commandline. Since September 2022 there is also a backup-complete message for LibuiParadise.
#
1365 1366 1367 1368 1369 1370 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1365 def e "#{BackupParadise.steelblue('Backup complete!')}#{rev}" # The old colour was cyan, up until 2021. if TRY_TO_SHOW_BACKUP_COMPLETE_MESSAGE_VIA_LIBUI end end |
#show_help ⇒ Object Also known as: display_help
#
show_help
#
266 267 268 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 266 def show_help BackupParadise.show_help end |
#show_popup_notification? ⇒ Boolean
#
show_popup_notification?
#
497 498 499 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 497 def show_popup_notification? @internal_hash[:show_popup_notification] end |
#show_the_logfile ⇒ Object
#
show_the_logfile
To invoke this method from the commandline, try:
advanced_backup --logfile?
#
480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 480 def show_the_logfile _ = FILE_BACKUP_LOG if File.exist? _ opne "Now reading the dataset from the file `#{sfile(_)}`:" e File.readlines(_).each {|line| e orangered(" #{line.chomp}") } e else opne no_file_exists_at(_) end end |
#show_welcome_message ⇒ Object
#
show_welcome_message
#
668 669 670 671 672 673 674 675 676 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 668 def print_rev cliner e "#{rev}Welcome to the #{lightcoral('BackupParadise')} #{rev}project!" report_todays_date cliner e "#{rev}Starting to backup into the target at `#{sdir(main_target?)}#{rev}`." cliner end |
#simplify_the_directory_layout? ⇒ Boolean
#
simplify_the_directory_layout?
#
273 274 275 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 273 def simplify_the_directory_layout? @internal_hash[:simplify_the_directory_layout] end |
#start_the_gtk3_bindings ⇒ Object
#
start_the_gtk3_bindings
To invoke this method, try:
rbackup --gui
rbackup --gtk
#
210 211 212 213 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 210 def start_the_gtk3_bindings require 'backup_paradise/gui/gtk3/simple_backup_widget/simple_backup_widget.rb' BackupParadise::GUI::Gtk::SimpleBackupWidget.run end |
#try_to_backup_the_autogenerated_directory(i = AUTOGENERATED_DIRECTORY) ⇒ Object Also known as: backup_autogenerated_directory, backup_the_autogenerated_directory
#
try_to_backup_the_autogenerated_directory
#
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1042 def try_to_backup_the_autogenerated_directory( i = AUTOGENERATED_DIRECTORY ) i = ensure_trailing_backslash_for(i) if File.directory? i opne 'Now trying to backup the AUTOGENERATED '\ 'directory at `'+sdir(i)+'`.' new_target = mountpoint?.squeeze('/') n_gigabytes = BackupParadise.size_in_gigabytes?(i).to_s opne 'This directory has a total of '+ sfancy(n_files_in?(i).to_s)+rev+ ' entries (Total size: '+n_gigabytes+' GB).' unless File.directory? new_target verbose_create_a_directory_at_this_position(new_target) end tab_title('Backing up the AUTOGENERATED directory.') cpr(i, new_target) else can_not_backup_this_directory_as_it_does_not_exist(i) end end |
#try_to_show_backup_complete_message_via_libui ⇒ Object
#
try_to_show_backup_complete_message_via_libui
This method will describe the libui-widget that we will use for notifying the user.
#
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1380 def begin require 'libui_paradise' text = LibuiParadise.text('Backup complete!') ::LibuiParadise.run_in_the_background LibuiParadise.generic_window( text, :create_a_quit_button ) {{ width: 420, height: 120, title: 'Backup is complete now!' }} rescue LoadError; end end |
#try_to_unmount_the_device ⇒ Object
#
try_to_unmount_the_device
This method can be used to automatically unmount the target device again.
#
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 400 def try_to_unmount_the_device this_is_the_mounted_device = backup_to_this_directory? # ======================================================================= # # Change directory to another directory where we can safely # umount the directory. # ======================================================================= # if has_superuser_abilities? if BackupParadise.target_mountpoint?.include?('HDD1') # =================================================================== # # Unmount harddiscs quickly. # =================================================================== # unmount :hdd # Since as of 17.06.2008 we will unmount the harddisc as well. end if File.directory? '/Depot/j/' cd '/Depot/j/' elsif File.directory? '/tmp' cd '/tmp' elsif File.directory? '/home/Temp' cd '/home/Temp' else cd '/' end opne "Next unmounting the device at "\ "`#{sfancy(this_is_the_mounted_device)}`." system "umount #{this_is_the_mounted_device}" end end |
#unmount(what = :hdd) ⇒ Object
#
unmount
Use this to unmount something. Right now, we unmount only the HDD.
#
1349 1350 1351 1352 1353 1354 1355 1356 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 1349 def unmount( what = :hdd ) case what.to_sym when :hdd system "umount -l #{ENV['FIRST_HD']}" end end |
#use_this_as_timestamp? ⇒ Boolean
#
use_this_as_timestamp?
#
356 357 358 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 356 def @internal_hash[:use_this_as_timestamp] end |
#verbose_create_a_directory_at_this_position(this_position, use_this_permission = 0754) ⇒ Object
#
verbose_create_a_directory_at_this_position
The first argument to this method should be the target directory, a path, that is where you wish to create that directory.
The second argument to this method, which is optional, denotes the permission that is to be used.
#
465 466 467 468 469 470 |
# File 'lib/backup_paradise/utility_scripts/backup/backup.rb', line 465 def verbose_create_a_directory_at_this_position( this_position, = 0754 ) e "Creating a directory at `#{sdir(this_position)}` next." mkdir(this_position, ) end |