Improvements for windows snapshots

freezer now recreate a snapshot if freezer symlink is present
and snapshots are now not used by default

Change-Id: Ie1aba42db7f74215c25593abcf2835400d8ebed2
This commit is contained in:
Memo Garcia 2015-11-16 12:05:33 +00:00 committed by Fausto Marzi
parent 3c79e9d07c
commit db6f59a200
2 changed files with 19 additions and 12 deletions

View File

@ -62,7 +62,7 @@ DEFAULT_PARAMS = {
'dry_run': False, 'lvm_snapsize': DEFAULT_LVM_SNAPSIZE,
'restore_abs_path': False, 'log_file': None,
'upload': True, 'mode': 'fs', 'action': 'backup',
'vssadmin': True, 'shadow': '', 'shadow_path': '',
'vssadmin': False, 'shadow': '', 'shadow_path': '',
'windows_volume': '', 'command': None, 'metadata_out': False,
'storage': 'swift', 'ssh_key': '', 'ssh_username': '', 'ssh_host': '',
'ssh_port': 22, 'compression': 'gzip'
@ -395,10 +395,10 @@ def backup_arguments(args_dict={}):
instance = <db-instance>''',
dest='sql_server_conf', default=False)
arg_parser.add_argument(
'--vssadmin', action='store',
'--vssadmin', action='store_true',
help='''Create a backup using a snapshot on windows
using vssadmin. Options are: True and False, default is True''',
dest='vssadmin', default=True)
dest='vssadmin', default=False)
arg_parser.add_argument(
'--command', action='store',
help='Command executed by exec action',
@ -486,9 +486,6 @@ def backup_arguments(args_dict={}):
backup_args.__dict__['windows_volume'] = \
backup_args.path_to_backup[:3]
if backup_args.vssadmin == 'False' or backup_args.vssadmin == 'false':
backup_args.vssadmin = False
# Freezer version
backup_args.__dict__['__version__'] = '1.1.3'

View File

@ -58,6 +58,9 @@ def vss_create_shadow_copy(windows_volume):
"""
shadow_path = None
shadow_id = None
vss_delete_symlink(windows_volume)
with DisableFileSystemRedirection():
path = os.path.dirname(os.path.abspath(__file__))
script = '{0}\\scripts\\vss.ps1'.format(path)
@ -97,14 +100,21 @@ def vss_delete_shadow_copy(shadow_id, windows_volume):
raise Exception('[*] Error deleting shadow copy with id {0}'
', error {1}' .format(shadow_id, err))
try:
os.rmdir(os.path.join(windows_volume, 'freezer_shadowcopy'))
except Exception:
logging.error('Failed to delete shadow copy symlink {0}'.
format(os.path.join(windows_volume,
'freezer_shadowcopy')))
vss_delete_symlink(windows_volume)
logging.info('[*] Deleting shadow copy {0}'.
format(shadow_id))
return True
def vss_delete_symlink(windows_volume):
"""Delete shadow copy symlink on the file system"""
path = os.path.join(windows_volume, 'freezer_shadowcopy')
try:
if os.path.exists(path):
os.rmdir(path)
except Exception:
logging.error('Failed to delete shadow copy symlink {0}'.
format(os.path.join(windows_volume,
'freezer_shadowcopy')))