Postgresql – How to create a backup of a single table in a postgres database

backuppg-dumppostgresql

Is there a way to create a backup of a single table within a database using postgres? And how? Does this also work with the pg_dump command?

Best Answer

Use --table to tell pg_dump what table it has to backup:

pg_dump --host localhost --port 5432 --username postgres --format plain --verbose --file "<abstract_file_path>" --table public.tablename dbname