From b47371cfe63c34212dcd23e35d62056596d57243 Mon Sep 17 00:00:00 2001 From: wpa-2 <9049886+wpa-2@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:45:28 +0000 Subject: [PATCH 1/3] Update defaults.toml Signed-off-by: wpa-2 <9049886+wpa-2@users.noreply.github.com> --- pwnagotchi/defaults.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwnagotchi/defaults.toml b/pwnagotchi/defaults.toml index 7ea38a50..3ea5e8fe 100644 --- a/pwnagotchi/defaults.toml +++ b/pwnagotchi/defaults.toml @@ -38,7 +38,7 @@ main.plugins.auto_backup.files = [ "/home/pi/.profile", "/home/pi/.wpa_sec_uploads", ] -main.plugins.auto_backup.commands = [ "tar czf {backup_file} {files}",] +main.plugins.auto_backup.commands = [ "tar cf {backup_file} {files}",] main.plugins.auto-tune.enabled = true From 5d4c2e3b3a1ac95972308cee3a972661dbbac0c7 Mon Sep 17 00:00:00 2001 From: wpa-2 <9049886+wpa-2@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:12:49 +0000 Subject: [PATCH 2/3] Add files via upload Signed-off-by: wpa-2 <9049886+wpa-2@users.noreply.github.com> --- pwnagotchi/plugins/default/auto_backup.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pwnagotchi/plugins/default/auto_backup.py b/pwnagotchi/plugins/default/auto_backup.py index cd381b0b..dcb135b3 100644 --- a/pwnagotchi/plugins/default/auto_backup.py +++ b/pwnagotchi/plugins/default/auto_backup.py @@ -8,9 +8,9 @@ import socket class AutoBackup(plugins.Plugin): __author__ = 'WPA2' - __version__ = '1.1.1' + __version__ = '1.1.3' __license__ = 'GPL3' - __description__ = 'Backs up files when internet is available, using new file list and options.' + __description__ = 'Backs up files when internet is available, with support for excludes.' def __init__(self): self.ready = False @@ -29,11 +29,9 @@ class AutoBackup(plugins.Plugin): return # If no custom command(s) are provided, use the default plain tar command. + # The command includes a placeholder for {excludes} so that if no excludes are set, it will be empty. if 'commands' not in self.options or not self.options['commands']: - self.options['commands'] = ["tar cf {backup_file} {files}"] - # For a tar.gz archive, use: - # self.options['commands'] = ["tar czf {backup_file} {files}"] - + self.options['commands'] = ["tar cf {backup_file} {excludes} {files}"] self.ready = True logging.info("AUTO-BACKUP: Successfully loaded.") @@ -88,7 +86,7 @@ class AutoBackup(plugins.Plugin): if not self.is_backup_due(): now = time.time() - # Log "backup not due" only once every 60 seconds + # Log "backup not due" only once every 60 seconds. if now - self.last_not_due_logged > 60: logging.info("AUTO-BACKUP: Backup not due yet based on the interval.") self.last_not_due_logged = now @@ -101,6 +99,14 @@ class AutoBackup(plugins.Plugin): return files_to_backup = " ".join(existing_files) + # Build excludes string if configured. + # Use get() so that if 'exclude' is missing or empty, we default to an empty list. + excludes = "" + exclude_list = self.options.get('exclude', []) + if exclude_list: + for pattern in exclude_list: + excludes += f" --exclude='{pattern}'" + # Get the backup location from config. backup_location = self.options['backup_location'] @@ -121,7 +127,7 @@ class AutoBackup(plugins.Plugin): # Execute each backup command. for cmd in self.options['commands']: - formatted_cmd = cmd.format(backup_file=backup_file, files=files_to_backup) + formatted_cmd = cmd.format(backup_file=backup_file, files=files_to_backup, excludes=excludes) logging.info(f"AUTO-BACKUP: Running command: {formatted_cmd}") process = subprocess.Popen( formatted_cmd, From 19de2a2d8f7b3009560d793ac23e7b2b0dc61f4e Mon Sep 17 00:00:00 2001 From: wpa-2 <9049886+wpa-2@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:13:15 +0000 Subject: [PATCH 3/3] Update defaults.toml Signed-off-by: wpa-2 <9049886+wpa-2@users.noreply.github.com> --- pwnagotchi/defaults.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pwnagotchi/defaults.toml b/pwnagotchi/defaults.toml index 3ea5e8fe..cb111515 100644 --- a/pwnagotchi/defaults.toml +++ b/pwnagotchi/defaults.toml @@ -38,6 +38,7 @@ main.plugins.auto_backup.files = [ "/home/pi/.profile", "/home/pi/.wpa_sec_uploads", ] +main.plugins.auto_backup.exclude = [ "/etc/pwnagotchi/logs/*",] main.plugins.auto_backup.commands = [ "tar cf {backup_file} {files}",] main.plugins.auto-tune.enabled = true