54 lines
2.0 KiB
Bash
Executable File
54 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
source /Users/noahheague/.config/scripts/util/secret.sh
|
|
export B2_ACCOUNT_ID=$(getSecret "/server/mac-mini-1/b2-account-id")
|
|
export B2_ACCOUNT_KEY=$(getSecret "/server/mac-mini-1/b2-account-key")
|
|
|
|
/Users/noahheague/.config/scripts/util/webhook.sh \
|
|
-c "backup" \
|
|
-m "Restic Backup Started..."
|
|
|
|
# Reclone download external files
|
|
/Users/noahheague/.config/scripts/util/webhook.sh \
|
|
-c "backup" \
|
|
-m "Pulling external files..."
|
|
|
|
/usr/local/bin/rclone copy Dropbox:Delta\ Emulator /Volumes/Homelab/30\ Archival/34\ Assorted/Delta\ Emulator
|
|
|
|
/Users/noahheague/.config/scripts/util/webhook.sh \
|
|
-c "backup" \
|
|
-m "Pushing to remote..."
|
|
|
|
/usr/local/bin/restic \
|
|
--pack-size 128 \
|
|
-r b2:pfych-home-server-backup:/ \
|
|
backup /Volumes/Homelab/ \
|
|
--verbose=2 \
|
|
--json \
|
|
--password-file <(source /Users/noahheague/.config/scripts/util/secret.sh; getSecret '/server/mac-mini-1/restic-key') \
|
|
--exclude "40 Programming/Docker/nginx-proxy-manager/data/nginx" \
|
|
--exclude "50 BitTorrent" \
|
|
--exclude "30 Archival/35 BMS" \
|
|
--exclude "30 Archival/32 Youtube/kkm" \
|
|
--exclude "Mastodon/public" \
|
|
--exclude "node_modules" \
|
|
--exclude ".fseventsd" \
|
|
--exclude ".Spotlight-V100" \
|
|
--exclude ".Trash-1000" \
|
|
--exclude ".DS_Store" \
|
|
--exclude ".DocumentRevisions-V100" \
|
|
--exclude ".TemporaryItems" \
|
|
--exclude ".Trashes" | jq 'select(.message_type | test("summary"))' > /tmp/restic-backup.json
|
|
|
|
/Users/noahheague/.config/scripts/util/webhook.sh \
|
|
-c "backup" \
|
|
-m "Restic Backup Completed!"
|
|
|
|
TIME_TAKEN=$(gdate -d@"$(cat /tmp/restic-backup.json | jq '.total_duration')" -u +%H:%M:%S)
|
|
FILES_CHANGED=$(cat /tmp/restic-backup.json | jq '.files_changed')
|
|
DIRECTORIES_CHANGED=$(cat /tmp/restic-backup.json | jq '.dirs_changed')
|
|
DATA_ADDED=$(units -t -o "%.0f" "$(cat /tmp/restic-backup.json | jq '.data_added') bytes" megabytes)
|
|
|
|
/Users/noahheague/.config/scripts/util/webhook.sh \
|
|
-c "backup" \
|
|
-m "Time Taken: $TIME_TAKEN\nFiles Changed: $FILES_CHANGED\nDirectories Changed: $DIRECTORIES_CHANGED\nData Added: ${DATA_ADDED}MB" |