Last active
February 1, 2023 06:01
-
-
Save macowie/f1f1f66a9e994366a957800333ba2a5a to your computer and use it in GitHub Desktop.
Online backup of my offline backup script
This file contains 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 | |
set -e | |
# Simple backup script for offline drives | |
# Keep a copy on drive with a sources.txt listing the paths this drive should backup | |
# /mnt/Milpool/Media/Music | |
# /mnt/Milpool/appdata_backups | |
# ... | |
SCRIPT_PATH=$(dirname $(realpath "$0")) | |
STARTED_AT=$(date --rfc-3339=s) | |
DESTINATION="${SCRIPT_PATH}/Backups" | |
SOURCE_ROOT="memorymu.lan:" | |
SOURCES=$(cat sources.txt) | |
CURRENT_TRANSFER_LOG="${DESTINATION}/backup-$(date -d "${STARTED_AT}" -u "+%Y%m%d-%H%M%S").log" | |
LAST_CAPTURED_LOG="${DESTINATION}/last-captured.log" | |
echo "🛫 SOURCES:" | |
echo $SOURCES | |
echo "🛬 DESTINATION: ${DESTINATION}" | |
for source in $SOURCES | |
do | |
echo "🫣 Backing up ${source} ..." | |
rsync --log-file="${CURRENT_TRANSFER_LOG}" -aqP "${SOURCE_ROOT}${source}/" "${DESTINATION}${source}" | |
done | |
echo "${STARTED_AT} -- ${SOURCES}" >> $LAST_CAPTURED_LOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment