A simple script utilizing rsync for both full and differential backups, and auto folder naming.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
3.3 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. # Mikes Backup
  2. Easily run both *full* and *differential* backups with rsync, to a local folder or an SSH server.
  3. 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:
  4. * You may easily force a *full* of *differential* backup type with a simple command line argument (see below)
  5. * 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
  6. * 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
  7. ## Requirements
  8. * rsync
  9. * python3
  10. * Backup destination accessible as a local directory OR a remote SSH server
  11. ## Command Line Arguments
  12. * ```--full``` Forces the script to run a *full* backup
  13. * ```--differential``` Forces the script to run a *differential* backup
  14. * ```--diff``` Same as ```---differential```
  15. * ```--no-incremental``` Always force differentials to link back to the *full* backup, and not the most recent *differential*
  16. * ```--log-dir <directory>``` Let's you set the log output directory
  17. * ```--log-name``` Let's you set a name to the log file
  18. * ```--source-dir <directory>``` Specifies the local source directory
  19. * ```--include <directory>``` Specifies another local source directory to include in the backup
  20. * ```--source-mountpoint <directory>``` Make sure a local mountpoint is mounted before continuing
  21. * ```--destination-dir <directory>``` Specifies the backup destination directory
  22. * ```--exclude <dir>``` Specifies a source directory to exclude (can be passed multiple times)
  23. * ```--remote-host <hostname>``` Specifies the remote host, if your backup destination is an SSH server
  24. * ```--remote-user <username>``` Specifies the remote username to use, if your backup destination is an SSH server
  25. * ```--ssh-key <path to key>``` Specifies the local SSH key to use for authentication, if your backup destination is an SSH server
  26. 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.
  27. ## Example
  28. 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)
  29. ```
  30. #!/bin/bash
  31. # Backup to an SSH server
  32. /path/to/mikes-backup \
  33. --log-dir "/my/log/dir/my-awesome-host-logs/" \
  34. --source-dir "/home/or/whatever/" \
  35. --destination-dir "/path/to/backup/destination/" \
  36. --remote-host "my-awesome-host.home" \
  37. --remote-user "my-remote-user" \
  38. --ssh-key "/home/me/.ssh/id_rsa" \
  39. --exclude "/my/dumb/downloads" \
  40. --exclude "/my/even/dumber/downloads"
  41. # Backup to a local folder
  42. /path/to/mikes-backup \
  43. --log-dir "/my/log/dir/local-backups/" \
  44. --source-dir "/home/or/whatever/" \
  45. --destination-dir "/local/path/to/backup/destination/" \
  46. --exclude "/my/dumb/downloads" \
  47. --exclude "/my/even/dumber/downloads"
  48. ```
  49. ## Questions
  50. 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