Search code examples
postgresqlherokupsqlpg-restore

Restoring postgresql from backup: pg_restore running out of memory error


I'm trying to restore a postgresql backup from production.

When I run pg_restore, the tables are created, but the process fails when trying to insert data. It runs out of memory.

pg_restore: processing data for table "public.annotations"
pg_restore(39098,0x10f25b5c0) malloc: can't allocate region
mach_vm_map(size=18446744073441116160) failed (error code=3)
pg_restore(39098,0x10f25b5c0) malloc: *** set a breakpoint in malloc_error_break to debug
out of memory**

The backup is only 29 MB in size. How can I make the restore work?


Solution

  • It turned out to be a corrupted database backup file. I used the prior backup and it restored as expected.