die "the backup was made for install directory '$BK_PREFIX', this host uses '$PREFIX' (use --prefix $BK_PREFIX)"
fi
log "backup: $SRC"
[ -f "$SRC/MANIFEST"]&& sed 's/^/ /'"$SRC/MANIFEST"
[ -f "$SRC/COMPLETE"]|| warn "the backup is not marked COMPLETE (an interrupted backup?)"
["$(manifest_get "$SRC" init)"="$INIT"]|| warn "the backup comes from a host with service manager '$(manifest_get "$SRC" init)', this one uses '$INIT': service definitions and the helper configuration are restored as saved"
log "verifying the backup"
verify_backup "$SRC"|| die "the backup is damaged or incomplete: nothing was changed"
log "code, databases, configuration, PKI and client profiles will be REPLACED by this backup (the current state is saved first)"
confirm "Stop the services and restore?"|| die "aborted by the user"
stop_app_services || die "could not stop the application services"
if["${OVPMON_NO_SAFETY_BACKUP:-0}" !=1];then
_safe="$BACKUP_ROOT/$(stamp)-pre-restore"
log "saving the current state first: $_safe"
mkdir -p "$BACKUP_ROOT"; chmod 700"$BACKUP_ROOT"
make_backup "$_safe" pre-restore "$PREFIX"|| die "the safety backup failed: nothing was changed"
fi
restore_all "$SRC""$PREFIX" full || die "the restore failed (see above). The backup is intact: $SRC"
log "restore complete"
if["$START"=1];then
svc_defs_reload ||true
start_app_services || die "the services did not start after the restore"
health_check "$(state_get OVPMON_HTTPS_PORT)"|| die "the health checks failed after the restore"
else
log "start the services when ready: $(for _s in $SERVICES;doprintf'%s '"$_s";done)(rc-service <name> start / systemctl start <name>)"