Rudi kwenye somo

Faili ya asili inayofanya kazi

restore.sh

Majina katika msimbo na maandishi ya kurasa za mfano zinazofanya kazi yamehifadhiwa kama yalivyo katika asili. Somo na maelekezo ya faili yanayafafanua kwa Kiswahili.

#!/usr/bin/env bash
set -euo pipefail
read -r -s -p 'EMPTY DISPOSABLE TARGET connection URL (never production): ' RESTORE_DATABASE_URL
printf '\n'
psql "$RESTORE_DATABASE_URL" --no-psqlrc -c 'select current_database(), inet_server_addr(), inet_server_port();'
read -r -p 'Confirm you checked that this is the empty disposable target; type RESTORE-PRACTICE: ' confirmation
if [[ "$confirmation" != RESTORE-PRACTICE ]]; then exit 1; fi
# No --clean and no DROP: existing table causes an error rather than being overwritten.
pg_restore --dbname="$RESTORE_DATABASE_URL" --exit-on-error --no-owner --no-privileges backups/practice-notes.dump
psql "$RESTORE_DATABASE_URL" --no-psqlrc -v ON_ERROR_STOP=1 -c 'select id, note from public.backup_practice_notes order by id;'