From 2e485505d408a9a75e5e41296b4eaaa7b8eb1974 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 27 Sep 2021 21:21:09 -0600 Subject: [PATCH] Skip backup sections if backup previously run --- scripts/auto_setup.py | 6 ------ scripts/wk/repairs/win.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/scripts/auto_setup.py b/scripts/auto_setup.py index 4ffc04b7..08b2a9ca 100644 --- a/scripts/auto_setup.py +++ b/scripts/auto_setup.py @@ -105,7 +105,6 @@ def no_op(*args): BASE_MENUS = { 'Groups': { 'Backup Settings': ( - # Add checks for existing backups and skip if detected MenuEntry('Backup Browsers', 'auto_backup_browser_profiles'), MenuEntry('Backup Power Plans', 'auto_backup_power_plans'), MenuEntry('Reset Power Plans', 'auto_reset_power_plans'), @@ -113,7 +112,6 @@ BASE_MENUS = { ), 'Install Software': ( MenuEntry('Visual C++ Runtimes', 'auto_install_vcredists'), - #MenuEntry('ESET NOD32 Antivirus', no_op), MenuEntry('Firefox', 'auto_install_firefox'), MenuEntry('LibreOffice', 'auto_install_libreoffice'), MenuEntry('Open Shell', 'auto_install_open_shell'), @@ -121,12 +119,9 @@ BASE_MENUS = { ), 'Configure System': ( MenuEntry('Chrome Notifications', 'auto_disable_chrome_notifications'), - #MenuEntry('O&O ShutUp 10', no_op), MenuEntry('Open Shell', 'auto_config_open_shell'), MenuEntry('uBlock Origin', 'auto_enable_ublock_origin'), - #MenuEntry('Disable Fast Startup', no_op), MenuEntry('Enable BSoD MiniDumps', 'auto_enable_bsod_minidumps'), - #MenuEntry('Enable Hibernation', no_op), MenuEntry('Enable RegBack', 'auto_enable_regback'), MenuEntry('Enable System Restore', 'auto_system_restore_enable'), MenuEntry('Set System Restore Size', 'auto_system_restore_set_size'), @@ -154,7 +149,6 @@ BASE_MENUS = { 'Run Programs': ( MenuEntry('Device Manager', no_op), MenuEntry('HWiNFO Sensors', no_op), - #MenuEntry('Snappy Driver Installer', no_op), MenuEntry('Windows Updates', no_op), MenuEntry('Windows Activation', no_op), MenuEntry('XMPlay', no_op), diff --git a/scripts/wk/repairs/win.py b/scripts/wk/repairs/win.py index 1f805722..b2964fd3 100644 --- a/scripts/wk/repairs/win.py +++ b/scripts/wk/repairs/win.py @@ -875,6 +875,16 @@ def backup_browser_chromium(backup_path, browser, search_path, use_try_print): if not match: continue output_path = backup_path.joinpath(f'{browser}-{item.name}.7z') + if output_path.exists(): + # Assuming backup was already done + if use_try_print: + show_data( + f'{" "*8}{browser} ({item.name})...', 'Backup already exists.', + color='YELLOW', width=WIDTH, + ) + continue + + # Backup data cmd = [ *BACKUP_BROWSER_BASE_CMD, output_path, item.joinpath('*'), '-x!*Cache*', '-x!Service Worker', @@ -891,6 +901,18 @@ def backup_browser_chromium(backup_path, browser, search_path, use_try_print): def backup_browser_firefox(backup_path, search_path, use_try_print): """Backup Firefox browser profile.""" output_path = backup_path.joinpath('Firefox.7z') + + # Bail early + if output_path.exists(): + # Assuming backup was already done + if use_try_print: + show_data( + f'{" "*8}Firefox (All)...', 'Backup already exists.', + color='YELLOW', width=WIDTH, + ) + return + + # Backup data cmd = [ *BACKUP_BROWSER_BASE_CMD, output_path, search_path.joinpath('Profiles'), search_path.joinpath('profiles.ini'), @@ -934,6 +956,12 @@ def backup_registry(): """Backup Registry.""" backup_path = set_backup_path('Registry', date=True) backup_path.parent.mkdir(parents=True, exist_ok=True) + + # Check if backup was already done today + if backup_path.exists(): + raise GenericWarning('Backup already exists.') + + # Backup registry extract_tool('ERUNT') run_tool('ERUNT', 'ERUNT', backup_path, 'sysreg', 'curuser', 'otherusers') @@ -1155,6 +1183,12 @@ def enable_windows_updates(): def export_power_plans(): """Export existing power plans.""" backup_path = set_backup_path('Power Plans', date=True) + + # Bail early + if backup_path.exists(): + raise GenericWarning('Backup already exists.') + + # Get powercfg data backup_path.mkdir(parents=True, exist_ok=True) cmd = ['powercfg', '/L'] proc = run_program(cmd)