From de9b172a660275be173efc04c35ace4b0e58dcb9 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Tue, 5 Aug 2025 17:34:21 -0400 Subject: [PATCH] added calibre backup script --- backup-calibre.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 backup-calibre.sh diff --git a/backup-calibre.sh b/backup-calibre.sh new file mode 100755 index 0000000..97c7c30 --- /dev/null +++ b/backup-calibre.sh @@ -0,0 +1,42 @@ + +#!/bin/bash + +# Calibre Library Backup Script +# This script backs up the Calibre Library to a network share + +# Configuration +SOURCE_DIR="/home/acedanger/Calibre Library/" +DEST_DIR="/mnt/share/media/books/" +LOG_FILE="/var/log/calibre-backup.log" + +# Function to log messages with timestamp +log_message() { + echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE" +} + +# Check if source directory exists +if [ ! -d "$SOURCE_DIR" ]; then + log_message "ERROR: Source directory does not exist: $SOURCE_DIR" + exit 1 +fi + +# Check if destination directory is accessible +if [ ! -d "$DEST_DIR" ]; then + log_message "ERROR: Destination directory not accessible: $DEST_DIR" + log_message "Make sure the network share is mounted" + exit 1 +fi + +# Start backup +log_message "Starting Calibre Library backup..." +log_message "Source: $SOURCE_DIR" +log_message "Destination: $DEST_DIR" + +# Perform the backup using rsync +if rsync -rtvp --delete --exclude="*.tmp" "$SOURCE_DIR" "$DEST_DIR" 2>&1 | tee -a "$LOG_FILE"; then + log_message "Backup completed successfully" + exit 0 +else + log_message "ERROR: Backup failed with exit code $?" + exit 1 +fi \ No newline at end of file