From 867df93c30af024b2710c6b76bf13d0de545a3e5 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 16 May 2019 14:30:14 -0600 Subject: [PATCH] Mount backup shares before adding block-pairs * Helps ensure saving map files to non-volatile storage * Addresses issue #74 --- .bin/Scripts/functions/ddrescue.py | 19 ++++++++++++++++--- .bin/Scripts/settings/ddrescue.py | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index 09de8388..ba65d933 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -61,9 +61,10 @@ class BlockPair(): if self.mode == 'clone': # Cloning self.dest_path = dest.path - self.map_path = '{pwd}/Clone_{prefix}.map'.format( - pwd=os.path.realpath(global_vars['Env']['PWD']), - prefix=source.prefix) + self.map_path = '{cwd}/Clone_{prefix}.map'.format( + cwd=os.path.realpath(os.getcwd()), + prefix=source.prefix, + ) else: # Imaging self.dest_path = '{path}/{prefix}.dd'.format( @@ -774,6 +775,7 @@ def is_writable_filesystem(dir_obj): def menu_ddrescue(source_path, dest_path, run_mode): """ddrescue menu.""" + map_dir = '{}/{}'.format(MAP_DIR, global_vars['Date-Time']) source = None dest = None if source_path: @@ -790,6 +792,17 @@ def menu_ddrescue(source_path, dest_path, run_mode): dest = select_path(skip_device=source) dest.self_check() + # Get Ticket ID + # TODO + # map_dir = '{}/{}_{}'.format(MAP_DIR, ticket_id, ticket_name) + + # Mount backup shares + mount_backup_shares(read_write=True) + + # Move to safe working dir + os.makedirs(map_dir, exist_ok=True) + os.chdir(map_dir) + # Build BlockPairs state = RecoveryState(run_mode, source, dest) if run_mode == 'clone': diff --git a/.bin/Scripts/settings/ddrescue.py b/.bin/Scripts/settings/ddrescue.py index 675019ca..8f0db99c 100644 --- a/.bin/Scripts/settings/ddrescue.py +++ b/.bin/Scripts/settings/ddrescue.py @@ -5,6 +5,7 @@ import re from collections import OrderedDict # General +MAP_DIR = '/Backups/Anaconda' RECOMMENDED_FSTYPES = ['ext3', 'ext4', 'xfs'] USAGE = """ {script_name} clone [source [destination]] {script_name} image [source [destination]]