From 341ad1f818c88481bfe7a3b1ffb042763f143151 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 6 Aug 2019 16:06:46 -0700 Subject: [PATCH] Add new option "--log-name" to set the log file's name --- README.md | 1 + mikes-backup | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca1f6a7..8089342 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ This script is really just a wrapper around rsync's beautiful functionality. It * ```--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 +* ```--log-name``` Let's you set a name to the log file * ```--source-dir ``` Specifies the local source directory * ```--include ``` Specifies another local source directory to include in the backup * ```--source-mountpoint ``` Make sure a local mountpoint is mounted before continuing diff --git a/mikes-backup b/mikes-backup index 7a2d0d3..13cba4a 100755 --- a/mikes-backup +++ b/mikes-backup @@ -15,6 +15,7 @@ class MikesBackup: # __log_dir = None + __log_name = None __remote_host = None __remote_user = None @@ -55,6 +56,7 @@ class MikesBackup: s += "MikesBackup Class Instance" s += "\nLog Dir: " + str(self.__log_dir) + s += "\nLog Name: " + str(self.__log_name) s += "\nRemote Host: " + str(self.__remote_host) s += "\nRemote User: " + str(self.__remote_user) s += "\nDestination Dir Base: " + str(self.__destination_dir_base) @@ -150,6 +152,12 @@ class MikesBackup: self.__log_dir = sys.argv[a + 1] self.log("Found log dir: " + self.__log_dir) a = a + 1 + elif arg == "--log-name": + valid_arg = True + self.__log_name = sys.argv[a + 1] + self.log("Found log name: " + self.__log_name) + self.close_log_file() + a = a + 1 elif arg == "--source-dir": valid_arg = True if self.__source_dir: @@ -439,8 +447,14 @@ class MikesBackup: if not log_dir: return None + # Filename + file_name = self.get_datetime_for_filename() + if self.__log_name: + file_name += "-" + self.__log_name + file_name += ".log" + # Path - log_path = os.path.join(log_dir, self.get_datetime_for_filename() + ".log") + log_path = os.path.join(log_dir, file_name) return log_path