Search code examples
postgresqlbackuppg-dump

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


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?


Solution

  • 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