Update README.md

This commit is contained in:
Mike Peralta 2018-09-02 03:21:58 -07:00 committed by GitHub
parent cc413a4a87
commit 31e5b8ab67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,44 +1,53 @@
# Mikes Backup # Mikes Backup
A simple python script utilizing rsync for both full and differential backups, and auto folder naming, over SSH Easily run both *full* and *differential* backups with rsync, to a local folder or an SSH server.
Honestly this is more of a wrapper around rsync's beautiful functionality. It simply makes daily backups slightly easier by: 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:
* Automatically choosing a *full* or *differential* backup type, based on whether it detects an existing *full* backup folder at the remote end * You may easily force a *full* of *differential* backup type with a simple command line argument (see below)
* Automatically generate a folder based on today's date and time, so you can generate a great many *differential* backup folders without manually changing anything * 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
## Requirements ## Requirements
* rsync * rsync
* python3 * python3
* Backup server accessible over SSH * Backup destination accessible as a local directory OR a remote SSH server
## Assumptions
* Your backup destination is an SSH server
## Command Line Arguments ## Command Line Arguments
* ```--full``` Forces the script to run a *full* backup * ```--full``` Forces the script to run a *full* backup
* ```--differential``` Forces the script to run a *differential* backup * ```--differential``` Forces the script to run a *differential* backup
* ```--log-dir <directory>``` Let's you set the log output directory * ```--log-dir <directory>``` Let's you set the log output directory
* ```--source-dir <directory>``` Specifies the local source directory * ```--source-dir <directory>``` Specifies the local source directory
* ```--remote-host <hostname>``` Specifies the remote host, to send the backups to over ssh * ```--destination-dir <directory>``` Specifies the backup destination directory
* ```--remote-user <username>``` Specifies the remote username to use, when connecting to the remote host * ```--remote-host <hostname>``` Specifies the remote host, if your backup destination is an SSH server
* ```--remote-dir <directory>``` Specifies the remote backup destination directory * ```--remote-user <username>``` Specifies the remote username to use, if your backup destination is an SSH server
* ```--ssh-key <path to key>``` Specifies the local ssh key to use for authentication * ```--ssh-key <path to key>``` Specifies the local SSH key to use for authentication, if your backup destination is an SSH server
* ```--exclude <dir>``` Specifies a source directory to exclude (can be passed multiple times) * ```--exclude <dir>``` Specifies a source directory to exclude (can be passed multiple times)
Note that ```--remote-host```, ```--remote-user```, and ```--ssh-key``` are only needed if your backup destination is a remote SSH server. You may omit all three if the destination is a locally mounted folder.
## Example ## Example
For daily use, you'll probably want to create a small bash script that calls this script with the parameters you want, and then call that with cron daily (or whatever your preference is) For daily use, you'll probably want to create a small bash script that calls this script with the parameters you want, and then call that with cron daily (or whatever your preference is)
``` ```
#!/bin/bash #!/bin/bash
# Backup to an SSH server
/path/to/mikes-backup \ /path/to/mikes-backup \
--log-dir "/my/log/dir" \ --log-dir "/my/log/dir/my-awesome-host-logs/" \
--source-dir "/home/or/whatever" \ --source-dir "/home/or/whatever/" \
--destination-dir "/path/to/backup/destination/" \
--remote-host "my-awesome-host.home" \ --remote-host "my-awesome-host.home" \
--remote-user "me" \ --remote-user "my-remote-user" \
--remote-dir "/path/to/backup/destination/on/remote/" \
--ssh-key "/home/me/.ssh/id_rsa" \ --ssh-key "/home/me/.ssh/id_rsa" \
--exclude "/my/dumb/downloads" \ --exclude "/my/dumb/downloads" \
--exclude "/my/even/dumber/downloads" --exclude "/my/even/dumber/downloads"
# Backup to a local folder
/path/to/mikes-backup \
--log-dir "/my/log/dir/local-backups/" \
--source-dir "/home/or/whatever/" \
--destination-dir "/local/path/to/backup/destination/" \
--exclude "/my/dumb/downloads" \
--exclude "/my/even/dumber/downloads"
``` ```
## Questions ## Questions