mikes-backup/README.md

61 lines
3.3 KiB
Markdown
Raw Normal View History

2018-09-01 05:16:26 -07:00
# Mikes Backup
2018-09-02 03:21:58 -07:00
Easily run both *full* and *differential* backups with rsync, to a local folder or an SSH server.
2018-09-01 05:16:04 -07:00
2018-09-02 03:21:58 -07:00
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:
* You may easily force a *full* of *differential* backup type with a simple command line argument (see below)
* 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
2018-09-01 05:16:04 -07:00
## Requirements
* rsync
* python3
2018-09-02 03:21:58 -07:00
* Backup destination accessible as a local directory OR a remote SSH server
2018-09-01 05:21:11 -07:00
2018-09-01 05:16:04 -07:00
## Command Line Arguments
* ```--full``` Forces the script to run a *full* backup
2018-09-01 05:21:39 -07:00
* ```--differential``` Forces the script to run a *differential* backup
2019-08-05 00:29:39 -07:00
* ```--diff``` Same as ```---differential```
* ```--no-incremental``` Always force differentials to link back to the *full* backup, and not the most recent *differential*
2018-09-01 05:16:04 -07:00
* ```--log-dir <directory>``` Let's you set the log output directory
* ```--log-name``` Let's you set a name to the log file
2018-09-01 05:16:04 -07:00
* ```--source-dir <directory>``` Specifies the local source directory
2019-08-05 00:29:39 -07:00
* ```--include <directory>``` Specifies another local source directory to include in the backup
* ```--source-mountpoint <directory>``` Make sure a local mountpoint is mounted before continuing
2018-09-02 03:21:58 -07:00
* ```--destination-dir <directory>``` Specifies the backup destination directory
2019-08-05 00:29:39 -07:00
* ```--exclude <dir>``` Specifies a source directory to exclude (can be passed multiple times)
2018-09-02 03:21:58 -07:00
* ```--remote-host <hostname>``` Specifies the remote host, if your backup destination is an SSH server
* ```--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, if your backup destination is an SSH server
2018-09-01 05:21:11 -07:00
2018-09-02 03:21:58 -07:00
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.
2018-09-01 05:21:11 -07:00
## 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)
2018-09-01 05:23:31 -07:00
```
#!/bin/bash
2018-09-01 05:21:11 -07:00
2018-09-02 03:21:58 -07:00
# Backup to an SSH server
2018-09-01 05:23:05 -07:00
/path/to/mikes-backup \
2018-09-02 03:21:58 -07:00
--log-dir "/my/log/dir/my-awesome-host-logs/" \
--source-dir "/home/or/whatever/" \
--destination-dir "/path/to/backup/destination/" \
2018-09-01 05:23:05 -07:00
--remote-host "my-awesome-host.home" \
2018-09-02 03:21:58 -07:00
--remote-user "my-remote-user" \
2018-09-01 05:23:05 -07:00
--ssh-key "/home/me/.ssh/id_rsa" \
--exclude "/my/dumb/downloads" \
--exclude "/my/even/dumber/downloads"
2018-09-02 03:21:58 -07:00
# 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"
2018-09-01 05:22:10 -07:00
```
2018-09-01 05:16:04 -07:00
## Questions
I realize these docs are sparse at best, so please send in questions if you have any, and I will try to update this file or create a Wiki if need be