|
@@ -24,6 +24,7 @@ import tempfile
|
|
|
|
|
|
from resource_management.core.logger import Logger
|
|
from resource_management.core.logger import Logger
|
|
from resource_management.core.exceptions import Fail
|
|
from resource_management.core.exceptions import Fail
|
|
|
|
+from resource_management.libraries.functions import tar_archive
|
|
|
|
|
|
BACKUP_TEMP_DIR = "knox-upgrade-backup"
|
|
BACKUP_TEMP_DIR = "knox-upgrade-backup"
|
|
BACKUP_DATA_ARCHIVE = "knox-data-backup.tar"
|
|
BACKUP_DATA_ARCHIVE = "knox-data-backup.tar"
|
|
@@ -51,15 +52,12 @@ def backup_data():
|
|
if os.path.exists(archive):
|
|
if os.path.exists(archive):
|
|
os.remove(archive)
|
|
os.remove(archive)
|
|
|
|
|
|
- tarball = None
|
|
|
|
- try:
|
|
|
|
- tarball = tarfile.open(archive, "w")
|
|
|
|
- tarball.add(directory, arcname=os.path.basename(directory))
|
|
|
|
- finally:
|
|
|
|
- if tarball:
|
|
|
|
- tarball.close()
|
|
|
|
|
|
+ # backup the directory, following symlinks instead of including them
|
|
|
|
+ tar_archive.archive_directory_dereference(archive, directory)
|
|
|
|
+
|
|
return absolute_backup_dir
|
|
return absolute_backup_dir
|
|
|
|
|
|
|
|
+
|
|
def _get_directory_mappings():
|
|
def _get_directory_mappings():
|
|
"""
|
|
"""
|
|
Gets a dictionary of directory to archive name that represents the
|
|
Gets a dictionary of directory to archive name that represents the
|