This commit is contained in:
Lee
2025-05-10 04:19:26 +01:00
parent 90c539a5fe
commit 7c66fb7964

View File

@ -61,10 +61,17 @@ validate_config() {
exit 1 exit 1
fi fi
# Check if backup path exists and is accessible
if [ ! -d "${CONFIG[BACKUP_PATH]}" ]; then if [ ! -d "${CONFIG[BACKUP_PATH]}" ]; then
echo "Error: Backup path does not exist: ${CONFIG[BACKUP_PATH]}" echo "Error: Backup path does not exist: ${CONFIG[BACKUP_PATH]}"
exit 1 exit 1
fi fi
# Check if we have read permissions
if [ ! -r "${CONFIG[BACKUP_PATH]}" ]; then
echo "Error: No read permission for backup path: ${CONFIG[BACKUP_PATH]}"
exit 1
fi
} }
parse_arguments() { parse_arguments() {
@ -249,14 +256,22 @@ main() {
# Run backup # Run backup
log "Running backup..." log "Running backup..."
log "Command: restic -r ${CONFIG[RESTIC_REPOSITORY]} backup ${CONFIG[BACKUP_PATH]}" log "Command: restic -r ${CONFIG[RESTIC_REPOSITORY]} backup ${CONFIG[BACKUP_PATH]}"
if ! restic -r "${CONFIG[RESTIC_REPOSITORY]}" backup "${CONFIG[BACKUP_PATH]}" >> "$BACKUP_LOG" 2>&1; then
log "Backup failed with exit code $?" # Check if restic command exists and is executable
if ! command -v restic >/dev/null 2>&1; then
log "Error: restic command not found"
backup_exit_code=1 backup_exit_code=1
else else
backup_exit_code=0 # Run the backup command and capture both stdout and stderr
log "Backup completed successfully" if ! restic -r "${CONFIG[RESTIC_REPOSITORY]}" backup "${CONFIG[BACKUP_PATH]}" >> "$BACKUP_LOG" 2>&1; then
# Add a small delay to ensure the snapshot is registered log "Backup failed. Check the log file for details: $BACKUP_LOG"
sleep 2 backup_exit_code=1
else
backup_exit_code=0
log "Backup completed successfully"
# Add a small delay to ensure the snapshot is registered
sleep 2
fi
fi fi
# Get snapshot information # Get snapshot information