Modified the photos notifications and logging to be more clear.
This commit is contained in:
@@ -144,28 +144,28 @@ fi
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Subtask 3.1: Sync most recent file in photos/backups directory
|
# Subtask 3.1: Sync most recent file in photos/backups directory
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
echo "Starting rsync of the most recent file in '$PHOTOS_BACKUP_SOURCE' to '$PHOTOS_DESTINATION'..."
|
echo "Starting rsync of the most recent database backup file in '$PHOTOS_BACKUP_SOURCE' to '$PHOTOS_DESTINATION'..."
|
||||||
|
|
||||||
if [ ! -d "$PHOTOS_BACKUP_SOURCE" ]; then
|
if [ ! -d "$PHOTOS_BACKUP_SOURCE" ]; then
|
||||||
echo "Error: Photos source directory '$PHOTOS_BACKUP_SOURCE' not found." >&2
|
echo "Error: Immich database backup source directory '$PHOTOS_BACKUP_SOURCE' not found." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Script failed. Photos source not found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Script failed. No database backup directory found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
# Find the most recent file in the directory.
|
# Find the most recent file in the directory.
|
||||||
LATEST_BACKUP_FILE=$(ls -t "$PHOTOS_BACKUP_SOURCE" | head -n 1)
|
LATEST_BACKUP_FILE=$(ls -t "$PHOTOS_BACKUP_SOURCE" | head -n 1)
|
||||||
|
|
||||||
# Check if a file was found.
|
# Check if a file was found.
|
||||||
if [ -z "$LATEST_BACKUP_FILE" ]; then
|
if [ -z "$LATEST_BACKUP_FILE" ]; then
|
||||||
echo "Error: No files found in Photos backup directory '$PHOTOS_BACKUP_SOURCE'." >&2
|
echo "Error: No files found in Immich database backup directory '$PHOTOS_BACKUP_SOURCE'." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: No files found in Photos backup directory." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: No database backup files found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
FULL_BACKUP_PATH="$PHOTOS_BACKUP_SOURCE/$LATEST_BACKUP_FILE"
|
FULL_BACKUP_PATH="$PHOTOS_BACKUP_SOURCE/$LATEST_BACKUP_FILE"
|
||||||
rsync -av --progress "$FULL_BACKUP_PATH" "$PHOTOS_DESTINATION"
|
rsync -av --progress "$FULL_BACKUP_PATH" "$PHOTOS_DESTINATION"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Success: Most recent Photos backup '$LATEST_BACKUP_FILE' copied to '$PHOTOS_DESTINATION'."
|
echo "Success: Most recent Immich database backup '$LATEST_BACKUP_FILE' copied to '$PHOTOS_DESTINATION'."
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Most recent Photos backup copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Most recent Immich database backup copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
echo "Error: rsync failed to copy photos backup file '$LATEST_BACKUP_FILE'. Please check permissions." >&2
|
echo "Error: rsync failed to copy most recent Immich database backup file '$LATEST_BACKUP_FILE'. Please check permissions." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy most recent Photos backup." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy most recent Immich database backup." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -175,16 +175,16 @@ fi
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
echo "Starting rsync of '$PHOTOS_LIBRARY_SOURCE' to '$PHOTOS_DESTINATION'..."
|
echo "Starting rsync of '$PHOTOS_LIBRARY_SOURCE' to '$PHOTOS_DESTINATION'..."
|
||||||
if [ ! -d "$PHOTOS_LIBRARY_SOURCE" ]; then
|
if [ ! -d "$PHOTOS_LIBRARY_SOURCE" ]; then
|
||||||
echo "Error: Photos source directory '$PHOTOS_LIBRARY_SOURCE' not found." >&2
|
echo "Error: Immich Library source directory '$PHOTOS_LIBRARY_SOURCE' not found." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Script failed. Photos library source not found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Script failed. Immich library source not found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
rsync -av --progress "$PHOTOS_LIBRARY_SOURCE" "$PHOTOS_DESTINATION"
|
rsync -av --progress "$PHOTOS_LIBRARY_SOURCE" "$PHOTOS_DESTINATION"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Success: Photos library directory copied to '$PHOTOS_DESTINATION'."
|
echo "Success: Immich library directory copied to '$PHOTOS_DESTINATION'."
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Photos library copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Immich library copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
echo "Error: rsync failed to copy photos library directory. Please check permissions." >&2
|
echo "Error: rsync failed to copy Immich library directory. Please check permissions." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy photos library directory." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy Immich library directory." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -193,16 +193,16 @@ fi
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
echo "Starting rsync of '$PHOTOS_PROFILE_SOURCE' to '$PHOTOS_DESTINATION'..."
|
echo "Starting rsync of '$PHOTOS_PROFILE_SOURCE' to '$PHOTOS_DESTINATION'..."
|
||||||
if [ ! -d "$PHOTOS_PROFILE_SOURCE" ]; then
|
if [ ! -d "$PHOTOS_PROFILE_SOURCE" ]; then
|
||||||
echo "Error: Photos source directory '$PHOTOS_PROFILE_SOURCE' not found." >&2
|
echo "Error: Immich Profile source directory '$PHOTOS_PROFILE_SOURCE' not found." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Script failed. Photos profile source not found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Immich Profile directory copy failed. Profile directory source not found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
rsync -av --progress "$PHOTOS_PROFILE_SOURCE" "$PHOTOS_DESTINATION"
|
rsync -av --progress "$PHOTOS_PROFILE_SOURCE" "$PHOTOS_DESTINATION"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Success: Photos profile directory copied to '$PHOTOS_DESTINATION'."
|
echo "Success: Immich profile directory copied to '$PHOTOS_DESTINATION'."
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Photos profile copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Immich profile directory copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
echo "Error: rsync failed to copy photos profile directory. Please check permissions." >&2
|
echo "Error: rsync failed to copy Immich profile directory. Please check permissions." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy photos profile directory." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy Immich profile directory." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -211,16 +211,16 @@ fi
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
echo "Starting rsync of '$PHOTOS_UPLOAD_SOURCE' to '$PHOTOS_DESTINATION'..."
|
echo "Starting rsync of '$PHOTOS_UPLOAD_SOURCE' to '$PHOTOS_DESTINATION'..."
|
||||||
if [ ! -d "$PHOTOS_UPLOAD_SOURCE" ]; then
|
if [ ! -d "$PHOTOS_UPLOAD_SOURCE" ]; then
|
||||||
echo "Error: Photos source directory '$PHOTOS_UPLOAD_SOURCE' not found." >&2
|
echo "Error: Immich upload source directory '$PHOTOS_UPLOAD_SOURCE' not found." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Script failed. Photos upload source not found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: Immich Upload directory copy failed. Upload directory source not found." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
rsync -av --progress "$PHOTOS_UPLOAD_SOURCE" "$PHOTOS_DESTINATION"
|
rsync -av --progress "$PHOTOS_UPLOAD_SOURCE" "$PHOTOS_DESTINATION"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Success: Photos upload directory copied to '$PHOTOS_DESTINATION'."
|
echo "Success: Immich upload directory copied to '$PHOTOS_DESTINATION'."
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Photos upload copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Success: Immich upload directory copied to $PHOTOS_DESTINATION" "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
echo "Error: rsync failed to copy photos upload directory. Please check permissions." >&2
|
echo "Error: rsync failed to copy Immich upload directory. Please check permissions." >&2
|
||||||
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy photos upload directory." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
curl -H "Authorization: Bearer $NTFY_TOKEN" -d "Error: rsync failed to copy Immich upload directory." "$NTFY_SERVER/$NTFY_TOPIC" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user