This commit is contained in:
Lee
2025-05-10 04:25:37 +01:00
parent 95ff9142b5
commit b89b29daa8

View File

@ -291,9 +291,19 @@ main() {
# Test restic repository access # Test restic repository access
log "Testing repository access..." log "Testing repository access..."
if ! restic -r "${CONFIG[RESTIC_REPOSITORY]}" snapshots 2>&1 | tee -a "$BACKUP_LOG"; then if ! restic -r "${CONFIG[RESTIC_REPOSITORY]}" snapshots 2>&1 | tee -a "$BACKUP_LOG"; then
log "Error: Cannot access repository. Please check your credentials and repository URL." log "Repository not initialized. Attempting to initialize..."
if ! restic -r "${CONFIG[RESTIC_REPOSITORY]}" init 2>&1 | tee -a "$BACKUP_LOG"; then
log "Error: Failed to initialize repository. Please check your credentials and repository URL."
backup_exit_code=1 backup_exit_code=1
else else
log "Repository initialized successfully"
backup_exit_code=0
fi
else
backup_exit_code=0
fi
if [ $backup_exit_code -eq 0 ]; then
# 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]}"