Junior — Middle
Have you ever performed a backup of a PostgreSQL database?
sobes.tech AI
Answer from AI
Yes, backing up a PostgreSQL database is usually done using the pg_dump utility.
Example of creating a backup:
pg_dump -U username -h hostname -F c -b -v -f backup_file.backup dbname
-U— database username-h— server host-F c— backup format (custom)-b— include large objects-v— verbose output-f— file to save the backup
You can also use pg_basebackup to create a physical copy of the database.
For restoration, the pg_restore or psql commands are used depending on the backup format.
It is important to plan backups considering downtime and data volume.