How to create a backup of a single table in a postgres database?

Elitmiar picture Elitmiar · Sep 10, 2010 · Viewed 224.4k times · Source

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?

Answer

Frank Heikens picture Frank Heikens · Sep 10, 2010

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