From 42c5e918b6aad693bc40a14eb449a257a855e604 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sun, 19 Aug 2018 13:12:03 -0700 Subject: [PATCH] Added Registry backups to system_checklist cleanup --- .bin/Scripts/functions/cleanup.py | 25 +++++++++++++++++++++++++ .bin/Scripts/system_checklist.py | 2 ++ 2 files changed, 27 insertions(+) diff --git a/.bin/Scripts/functions/cleanup.py b/.bin/Scripts/functions/cleanup.py index a604a47c..945938a9 100644 --- a/.bin/Scripts/functions/cleanup.py +++ b/.bin/Scripts/functions/cleanup.py @@ -104,6 +104,31 @@ def cleanup_emsisoft(): if os.path.exists(source_path): shutil.rmtree(source_path) +def cleanup_regbackups(): + """Move d7ii regbackups into backup folder.""" + source_path = r'{}\Support\RegBackups'.format( + global_vars['Env']['SYSTEMDRIVE']) + + # Bail early + if not os.path.exists(source_path): + return + + # Move to backup folder + for entry in os.scandir(source_path): + os.makedirs(global_vars['ProgBackupDir'], exist_ok=True) + dest_path = r'{ProgBackupDir}\{Date}\Registry\{name}'.format( + name=entry.name, + **global_vars) + dest_path = non_clobber_rename(dest_path) + shutil.move(entry.path, dest_path) + + # Delete source folders if empty + try: + os.rmdir(source_path) + os.rmdir(r'{}\Support'.format(global_vars['Env']['SYSTEMDRIVE'])) + except OSError: + pass + if __name__ == '__main__': print("This file is not meant to be called directly.") diff --git a/.bin/Scripts/system_checklist.py b/.bin/Scripts/system_checklist.py index 788af936..6fdbcf79 100644 --- a/.bin/Scripts/system_checklist.py +++ b/.bin/Scripts/system_checklist.py @@ -50,6 +50,8 @@ if __name__ == '__main__': function=cleanup_desktop, cs='Done') try_and_print(message='Emsisoft a2cmd...', function=cleanup_emsisoft, cs='Done') + try_and_print(message='Registry Backup(s)...', + function=cleanup_regbackups, cs='Done') # Export system info if not D7_MODE: