Skip to content

Commit

Permalink
Merge pull request #163 from antonlacon/le10-backup-filter
Browse files Browse the repository at this point in the history
filter certain paths from backup
  • Loading branch information
chewitt authored Mar 10, 2021
2 parents d8796af + d65acfa commit 7f4fd45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions resources/lib/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
CONFIG_CACHE,
'/storage/.ssh',
],
'BACKUP_FILTER' : [
f'{XBMC_USER_HOME}/addons/packages',
f'{XBMC_USER_HOME}/addons/temp',
f'{XBMC_USER_HOME}/temp'
],
'BACKUP_DESTINATION': '/storage/backup/',
'RESTORE_DIR': '/storage/.restore/',
}
Expand Down
7 changes: 5 additions & 2 deletions resources/lib/modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class system(modules.Module):
UDEV_KEYBOARD_INFO = None
NOX_KEYBOARD_INFO = None
BACKUP_DIRS = None
BACKUP_FILTER = None
BACKUP_DESTINATION = None
RESTORE_DIR = None
SET_CLOCK_CMD = None
Expand Down Expand Up @@ -538,7 +539,9 @@ def tar_add_folder(self, tar, folder):
pass
return 0
itempath = os.path.join(folder, item)
if os.path.islink(itempath):
if itempath in self.BACKUP_FILTER:
continue
elif os.path.islink(itempath):
tar.add(itempath)
elif os.path.ismount(itempath):
tar.add(itempath, recursive=False)
Expand All @@ -561,7 +564,7 @@ def tar_add_folder(self, tar, folder):
def get_folder_size(self, folder):
for item in os.listdir(folder):
itempath = os.path.join(folder, item)
if os.path.islink(itempath):
if itempath in self.BACKUP_FILTER or os.path.islink(itempath):
continue
elif os.path.isfile(itempath):
self.total_backup_size += os.path.getsize(itempath)
Expand Down

0 comments on commit 7f4fd45

Please sign in to comment.