Browse Source

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

remotes/github/dev
Mike 1 year ago
parent
commit
341ad1f818
2 changed files with 16 additions and 1 deletions
  1. +1
    -0
      README.md
  2. +15
    -1
      mikes-backup

+ 1
- 0
README.md View File

@@ -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 <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
* ```--include <directory>``` Specifies another local source directory to include in the backup
* ```--source-mountpoint <directory>``` Make sure a local mountpoint is mounted before continuing


+ 15
- 1
mikes-backup View File

@@ -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


Loading…
Cancel
Save