Add new option "--log-name" to set the log file's name

This commit is contained in:
Mike 2019-08-06 16:06:46 -07:00
parent 165787f819
commit 341ad1f818
2 changed files with 16 additions and 1 deletions

View File

@ -17,6 +17,7 @@ This script is really just a wrapper around rsync's beautiful functionality. It
* ```--diff``` Same as ```---differential``` * ```--diff``` Same as ```---differential```
* ```--no-incremental``` Always force differentials to link back to the *full* backup, and not the most recent *differential* * ```--no-incremental``` Always force differentials to link back to the *full* backup, and not the most recent *differential*
* ```--log-dir <directory>``` Let's you set the log output directory * ```--log-dir <directory>``` Let's you set the log output directory
* ```--log-name``` Let's you set a name to the log file
* ```--source-dir <directory>``` Specifies the local source directory * ```--source-dir <directory>``` Specifies the local source directory
* ```--include <directory>``` Specifies another local source directory to include in the backup * ```--include <directory>``` Specifies another local source directory to include in the backup
* ```--source-mountpoint <directory>``` Make sure a local mountpoint is mounted before continuing * ```--source-mountpoint <directory>``` Make sure a local mountpoint is mounted before continuing

View File

@ -15,6 +15,7 @@ class MikesBackup:
# #
__log_dir = None __log_dir = None
__log_name = None
__remote_host = None __remote_host = None
__remote_user = None __remote_user = None
@ -55,6 +56,7 @@ class MikesBackup:
s += "MikesBackup Class Instance" s += "MikesBackup Class Instance"
s += "\nLog Dir: " + str(self.__log_dir) s += "\nLog Dir: " + str(self.__log_dir)
s += "\nLog Name: " + str(self.__log_name)
s += "\nRemote Host: " + str(self.__remote_host) s += "\nRemote Host: " + str(self.__remote_host)
s += "\nRemote User: " + str(self.__remote_user) s += "\nRemote User: " + str(self.__remote_user)
s += "\nDestination Dir Base: " + str(self.__destination_dir_base) s += "\nDestination Dir Base: " + str(self.__destination_dir_base)
@ -150,6 +152,12 @@ class MikesBackup:
self.__log_dir = sys.argv[a + 1] self.__log_dir = sys.argv[a + 1]
self.log("Found log dir: " + self.__log_dir) self.log("Found log dir: " + self.__log_dir)
a = a + 1 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": elif arg == "--source-dir":
valid_arg = True valid_arg = True
if self.__source_dir: if self.__source_dir:
@ -439,8 +447,14 @@ class MikesBackup:
if not log_dir: if not log_dir:
return None return None
# Filename
file_name = self.get_datetime_for_filename()
if self.__log_name:
file_name += "-" + self.__log_name
file_name += ".log"
# Path # 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 return log_path