Closed aatmanvaidya closed 5 months ago
Command to access postgres using psql
psql -h postgres -p 5432 -U tattle -d postgres
take the backup of the data using pg_dump
RUN apt-get update && apt-get -y upgrade && \
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
apt-get update && apt-get install -y postgresql-client-16
Take the backup of the data
pg_dump -U tattle -h postgres -p 5432 postgres > data.sql
restore the data back up
psql -U tattle -h postgres -p 5432 -d postgres < data.sql
This is the format username - host - port - dbname
add UUID value in postgre using SQL - https://stackoverflow.com/questions/52067058/how-to-autogenerate-uuid-for-postgres-in-python
Fix commit and rollback issues - https://stackoverflow.com/questions/2979369/databaseerror-current-transaction-is-aborted-commands-ignored-until-end-of-tra See for good explaination - https://stackoverflow.com/questions/10399727/psqlexception-current-transaction-is-aborted-commands-ignored-until-end-of-tra
Backup and Restore PostgreSQL database - https://www.postgresql.org/docs/current/backup-dump.html