Skip to content

Commit

Permalink
[Fixes #10195] Backup and restore procedure is not successful (#10196) (
Browse files Browse the repository at this point in the history
#10203)

* [Fixes #10195] Backup and restore procedure is not successful

* [Fixes #10195] Backup and restore procedure is not successful

* [Fixes #10195] Backup and restore procedure is not successful

* [Fixes #10195] Backup and restore procedure is not successful

* [Fixes #10195] Backup and restore procedure is not successful

* [Fixes #10195] test fix build

Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and mattiagiupponi authored Oct 27, 2022
1 parent 9469b5d commit c97b058
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
24 changes: 12 additions & 12 deletions geonode/br/management/commands/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ def execute_backup(self, **options):

for static_files_folder in static_folders:

# skip dumping of static files of apps not located under LOCAL_ROOT path
# skip dumping of static files of apps not located under PROJECT_ROOT path
# (check to prevent saving files from site-packages in project-template based GeoNode projects)
if getattr(settings, 'LOCAL_ROOT', None) and \
not static_files_folder.startswith(settings.LOCAL_ROOT):
if getattr(settings, 'PROJECT_ROOT', None) and \
not static_files_folder.startswith(settings.PROJECT_ROOT):
print(f"Skipping static directory: {static_files_folder}. "
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
continue

static_folder = os.path.join(static_files_folders,
Expand All @@ -221,12 +221,12 @@ def execute_backup(self, **options):

for template_files_folder in template_folders:

# skip dumping of template files of apps not located under LOCAL_ROOT path
# skip dumping of template files of apps not located under PROJECT_ROOT path
# (check to prevent saving files from site-packages in project-template based GeoNode projects)
if getattr(settings, 'LOCAL_ROOT', None) and \
not template_files_folder.startswith(settings.LOCAL_ROOT):
if getattr(settings, 'PROJECT_ROOT', None) and \
not template_files_folder.startswith(settings.PROJECT_ROOT):
print(f"Skipping template directory: {template_files_folder}. "
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
continue

template_folder = os.path.join(template_files_folders,
Expand All @@ -246,12 +246,12 @@ def execute_backup(self, **options):

for locale_files_folder in locale_folders:

# skip dumping of locale files of apps not located under LOCAL_ROOT path
# skip dumping of locale files of apps not located under PROJECT_ROOT path
# (check to prevent saving files from site-packages in project-template based GeoNode projects)
if getattr(settings, 'LOCAL_ROOT', None) and \
not locale_files_folder.startswith(settings.LOCAL_ROOT):
if getattr(settings, 'PROJECT_ROOT', None) and \
not locale_files_folder.startswith(settings.PROJECT_ROOT):
logger.info(f"Skipping locale directory: {locale_files_folder}. "
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
continue

locale_folder = os.path.join(locale_files_folders,
Expand Down
42 changes: 24 additions & 18 deletions geonode/br/management/commands/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,20 @@ def execute_restore(self, **options):
print(f"[Sanity Check] Full Write Access to '{static_root}' ...")
chmod_tree(static_root)
for static_files_folder in static_folders:
print(f"[Sanity Check] Full Write Access to '{static_files_folder}' ...")
chmod_tree(static_files_folder)
if getattr(settings, 'PROJECT_ROOT', None) and \
static_files_folder.startswith(settings.PROJECT_ROOT):
print(f"[Sanity Check] Full Write Access to '{static_files_folder}' ...")
chmod_tree(static_files_folder)
for template_files_folder in template_folders:
print(f"[Sanity Check] Full Write Access to '{template_files_folder}' ...")
chmod_tree(template_files_folder)
if getattr(settings, 'PROJECT_ROOT', None) and \
template_files_folder.startswith(settings.PROJECT_ROOT):
print(f"[Sanity Check] Full Write Access to '{template_files_folder}' ...")
chmod_tree(template_files_folder)
for locale_files_folder in locale_folders:
print(f"[Sanity Check] Full Write Access to '{locale_files_folder}' ...")
chmod_tree(locale_files_folder)
if getattr(settings, 'PROJECT_ROOT', None) and \
locale_files_folder.startswith(settings.PROJECT_ROOT):
print(f"[Sanity Check] Full Write Access to '{locale_files_folder}' ...")
chmod_tree(locale_files_folder)
except Exception as exception:
if notify:
restore_notification.apply_async(
Expand Down Expand Up @@ -400,14 +406,14 @@ def execute_restore(self, **options):
# Restore Static Folders
for static_files_folder in static_folders:

# skip restoration of static files of apps not located under LOCAL_ROOT path
# skip restoration of static files of apps not located under PROJECT_ROOT path
# (check to prevent overriding files from site-packages
# in project-template based GeoNode projects)
if getattr(settings, 'LOCAL_ROOT', None) and \
not static_files_folder.startswith(settings.LOCAL_ROOT):
if getattr(settings, 'PROJECT_ROOT', None) and \
not static_files_folder.startswith(settings.PROJECT_ROOT):
print(
f"Skipping static directory: {static_files_folder}. "
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
continue

if config.gs_data_dt_filter[0] is None:
Expand All @@ -425,14 +431,14 @@ def execute_restore(self, **options):
# Restore Template Folders
for template_files_folder in template_folders:

# skip restoration of template files of apps not located under LOCAL_ROOT path
# skip restoration of template files of apps not located under PROJECT_ROOT path
# (check to prevent overriding files from site-packages
# in project-template based GeoNode projects)
if getattr(settings, 'LOCAL_ROOT', None) and \
not template_files_folder.startswith(settings.LOCAL_ROOT):
if getattr(settings, 'PROJECT_ROOT', None) and \
not template_files_folder.startswith(settings.PROJECT_ROOT):
print(
f"Skipping template directory: {template_files_folder}. "
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
continue

if config.gs_data_dt_filter[0] is None:
Expand All @@ -450,14 +456,14 @@ def execute_restore(self, **options):
# Restore Locale Folders
for locale_files_folder in locale_folders:

# skip restoration of locale files of apps not located under LOCAL_ROOT path
# skip restoration of locale files of apps not located under PROJECT_ROOT path
# (check to prevent overriding files from site-packages
# in project-template based GeoNode projects)
if getattr(settings, 'LOCAL_ROOT', None) and \
not locale_files_folder.startswith(settings.LOCAL_ROOT):
if getattr(settings, 'PROJECT_ROOT', None) and \
not locale_files_folder.startswith(settings.PROJECT_ROOT):
print(
f"Skipping locale directory: {locale_files_folder}. "
f"It's not located under LOCAL_ROOT path: {settings.LOCAL_ROOT}.")
f"It's not located under PROJECT_ROOT path: {settings.PROJECT_ROOT}.")
continue

if config.gs_data_dt_filter[0] is None:
Expand Down

0 comments on commit c97b058

Please sign in to comment.