20 Commits
v1.1.0 ... dev

Author SHA1 Message Date
8ed4f07bf4 nop to test hooks 2022-07-20 02:24:32 -07:00
ed7e4f7613 nop to test hooks 2022-07-20 02:23:21 -07:00
ed1f1beb0f Merge branch 'master' into dev 2022-07-20 02:18:17 -07:00
7b4a3feb0e Farewell update 2022-07-20 02:15:47 -07:00
a7bf367600 Merge branch 'dev' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup into dev 2020-05-13 09:07:29 -07:00
7977b1d827 Merge branch 'master' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup 2020-04-09 12:59:25 -07:00
3982a6865e Merge branch 'dev' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup into dev 2020-04-09 12:58:24 -07:00
cda638cad9 Merge branch 'master' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup 2020-04-07 18:11:59 -07:00
aa950740e0 Merge branch 'dev' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup into dev 2020-04-07 18:10:31 -07:00
066d5da4da Merge branch 'master' of ssh://git.mikeperalta.com:3222/misc-utilities/mikes-backup 2020-04-04 07:07:13 -07:00
7a871fd4a6 Merge branch 'dev' 2020-04-04 07:07:04 -07:00
7f3b7a0c01 Added some options to Rsync for: Verbose, One File System, Skip Links 2020-04-04 07:06:01 -07:00
1821fe453d Verbosity 2020-01-27 16:23:36 -08:00
dfe0a33315 noop to test hooks 2020-01-02 10:47:43 -08:00
6690a5fe0a Merge branch 'dev' 2019-08-06 23:24:38 -07:00
6cf4d49bc3 Bugfix -> When removing the diff folder after a full backup, only remote ssh destination was supported 2019-08-06 23:24:25 -07:00
03f49c2b82 Noop to test hook 2019-08-06 16:20:19 -07:00
369227027a Noop to test hook 2019-08-06 16:18:31 -07:00
7f53303cda Noop to test hook 2019-08-06 16:17:46 -07:00
341ad1f818 Add new option "--log-name" to set the log file's name 2019-08-06 16:06:46 -07:00
2 changed files with 37 additions and 8 deletions

View File

@ -1,4 +1,7 @@
# Mikes Backup # Mikes Backup
*** Currently Archived; Read Section Below ***
Easily run both *full* and *differential* backups with rsync, to a local folder or an SSH server. Easily run both *full* and *differential* backups with rsync, to a local folder or an SSH server.
This script is really just a wrapper around rsync's beautiful functionality. It presents a simplified interface for one very narrow use case: Simplifying the process of running daily backups: This script is really just a wrapper around rsync's beautiful functionality. It presents a simplified interface for one very narrow use case: Simplifying the process of running daily backups:
@ -6,6 +9,10 @@ This script is really just a wrapper around rsync's beautiful functionality. It
* Otherwise, it will automatically choose a *full* or *differential* backup type, based on whether it detects an existing *full* backup folder at the backup destination * Otherwise, it will automatically choose a *full* or *differential* backup type, based on whether it detects an existing *full* backup folder at the backup destination
* For *differential* backups, it automatically generates a folder based on today's date and time, making it easier to store many differentials without the need to manually fuss with anything * For *differential* backups, it automatically generates a folder based on today's date and time, making it easier to store many differentials without the need to manually fuss with anything
## Archive Status
I've decided to discontinue development of this project because [restic](https://restic.net/) is so much more robust, useful, and cool. *Mike's Backup* still works as of this writing (2022-07-20), but I've moved all my personal backups over to restic.
## Requirements ## Requirements
* rsync * rsync
* python3 * python3
@ -17,6 +24,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:
@ -276,7 +284,7 @@ class MikesBackup:
return False return False
# #
self.log("Checking for remote destination path") self.log("Checking for remote destination path: " + destination_path)
command = [ command = [
"[ -d " + destination_path + " ]" "[ -d " + destination_path + " ]"
] ]
@ -368,12 +376,15 @@ class MikesBackup:
self.log("Rsync seems to have finished successfully") self.log("Rsync seems to have finished successfully")
self.log("Because a full backup has succeeded, will now delete any differential backups") self.log("Because a full backup has succeeded, will now delete any differential backups")
self.execute_remote_ssh_command( args_remove_differentials = [
[ "rm",
"rm", "-rfv",
"-rfv", self.make_remote_differential_backup_path_base()
self.make_remote_differential_backup_path_base() ]
]) if self.is_using_ssh():
self.execute_remote_ssh_command(args_remove_differentials)
else:
self.execute_command(args_remove_differentials)
self.log("Finished deleting old differentials") self.log("Finished deleting old differentials")
# #
@ -439,8 +450,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
@ -641,8 +658,11 @@ class MikesBackup:
"--compress", "--compress",
"--progress", "--progress",
"--stats", "--stats",
"--verbose",
"--human-readable", "--human-readable",
"--itemize-changes", "--itemize-changes",
"--no-links",
"--one-file-system",
"--delete", "--delete",
"--delete-excluded" "--delete-excluded"
] ]
@ -747,6 +767,7 @@ class MikesBackup:
raise Exception("Unsupported command datatype") raise Exception("Unsupported command datatype")
# Spawn # Spawn
# print(args)
process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# process = subprocess.Popen(args) # process = subprocess.Popen(args)
stdout, stderr = process.communicate() stdout, stderr = process.communicate()