7
This commit is contained in:
14
backup.sh
14
backup.sh
@ -291,9 +291,19 @@ main() {
|
||||
# Test restic repository access
|
||||
log "Testing repository access..."
|
||||
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."
|
||||
backup_exit_code=1
|
||||
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
|
||||
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
|
||||
log "Running backup..."
|
||||
log "Command: restic -r ${CONFIG[RESTIC_REPOSITORY]} backup ${CONFIG[BACKUP_PATH]}"
|
||||
|
Reference in New Issue
Block a user