Created
February 16, 2026 01:34
-
-
Save bigntallmike/8806bf15698173525e119cbb691a28a0 to your computer and use it in GitHub Desktop.
Alternative borg backup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # This script is intended to be saved on a removable drive | |
| # and executed in place when that drive is mounted properly | |
| # For instance: | |
| # ./borgusbbackup oldlaptop /home /etc | |
| DATECODE=$(date +%Y%m%d%H%M%S) | |
| if [ "x$1" = "x" ]; then | |
| echo "Specify name of backup then folders to back up ..." | |
| exit 1 | |
| fi | |
| target="`pwd`/$1" | |
| # pop $1 off the stack | |
| shift | |
| echo "Backing up to $target ..." | |
| sleep 3 | |
| if [ ! -d "$target" ]; then | |
| borg init --encryption repokey $target || exit 1 | |
| fi | |
| borg create --verbose --progress --stats \ | |
| "$target::$DATECODE" "$@" 2>&1 | tee borg_backup_$DATECODE | |
| borg prune --verbose --progress --stats \ | |
| --keep-daily=5 \ | |
| --keep-weekly=3 \ | |
| --keep-monthly=6 2>&1 | tee borg_prune_$DATECODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment