Mount backup shares before adding block-pairs

* Helps ensure saving map files to non-volatile storage
* Addresses issue #74
This commit is contained in:
2Shirt 2019-05-16 14:30:14 -06:00
parent ce275d86a4
commit 867df93c30
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 17 additions and 3 deletions

View file

@ -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':

View file

@ -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]]