From 3622d365f1c8d1c65e8d39c4895abad40738c856 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 5 Aug 2019 01:30:27 -0700 Subject: [PATCH] Add new CLI parameter to disable incremental backups (ie: only use full as the link target; never a previous differential) --- README.md | 1 + mikes-backup | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a33b139..ca1f6a7 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ This script is really just a wrapper around rsync's beautiful functionality. It * ```--full``` Forces the script to run a *full* backup * ```--differential``` Forces the script to run a *differential* backup * ```--diff``` Same as ```---differential``` +* ```--no-incremental``` Always force differentials to link back to the *full* backup, and not the most recent *differential* * ```--log-dir ``` Let's you set the log output directory * ```--source-dir ``` Specifies the local source directory * ```--include ``` Specifies another local source directory to include in the backup diff --git a/mikes-backup b/mikes-backup index 6de1eeb..734a135 100755 --- a/mikes-backup +++ b/mikes-backup @@ -30,6 +30,7 @@ class MikesBackup: __force_full = False __force_differential = False + __no_incremental = False __log_file_handle = None @@ -59,12 +60,13 @@ class MikesBackup: s += "\nDestination Dir Base: " + str(self.__destination_dir_base) s += "\nSource Dir (Main): " + str(self.__source_dir) s += "\nSource Dirs (Includes): " + str(self.__source_dir_includes) - s += "\nSource Dir Excludes: " + str(self.__source_dir_excludes) + s += "\nSource Dirs (Excludes): " + str(self.__source_dir_excludes) s += "\nSource Mountpoint Demands: " + str(self.__source_mountpoint_demands) s += "\nSSH Key: " + str(self.__ssh_key) s += "\nQuiet SSH: " + str(self.__quiet_ssh) s += "\nForce Full Backup: " + str(self.__force_full) s += "\nForce Differential: " + str(self.__force_differential) + s += "\nDisallow Incremental: " + str(self.__no_incremental) return s @@ -141,6 +143,10 @@ class MikesBackup: valid_arg = True self.__force_differential = True self.log("Forcing a differential backup") + elif arg == "--no-incremental": + valid_arg = True + self.__no_incremental = True + self.log("Disallowing incremental backups (differentials will only link back to full)") elif arg == "--log-dir": valid_arg = True self.__log_dir = sys.argv[a + 1] @@ -534,7 +540,10 @@ class MikesBackup: if not newest_path: self.log("Didn't find a \"Full\" backup on remote") - # TODO: Add CLI option to disable incrementals (ie: don't consider the diff dirs for the rsync link arg) + if self.__no_incremental: + self.log("Incremental backups are disabled; Won't consider any differential directories for the link target") + return newest_path + # Get listing info for all differential directories differential_path_base = self.make_remote_differential_backup_path_base() return_code, stdout, stderr = self.execute_remote_ssh_command([