7
This commit is contained in:
14
backup.sh
14
backup.sh
@ -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..."
|
||||||
backup_exit_code=1
|
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
|
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]}"
|
||||||
|
Reference in New Issue
Block a user