Bloated PG backup
ashlinr
PROOP

a month ago

I have a small PG DB of about 80mb. When backing up using Railway dashboard it bloats to 1.33 GB. I have tried vacuuming etc. The volume is small so I don't know why the backup is so huge?

$20 Bounty

6 Replies

Railway
BOT

a month ago

Volume backups capture the entire contents of the volume, not just the logical database size. Your 80MB is likely the logical data size, but PostgreSQL's on-disk footprint includes WAL segments, indexes, TOAST tables, and other internal structures that are significantly larger. The 1.33GB backup reflects the actual disk usage of the full PostgreSQL data directory on the volume, which you can confirm by checking the volume's used size in the service settings.


Status changed to Awaiting User Response Railway about 1 month ago


Status changed to Awaiting Railway Response Railway about 1 month ago


Railway

Volume backups capture the entire contents of the volume, not just the logical database size. Your 80MB is likely the logical data size, but PostgreSQL's on-disk footprint includes WAL segments, indexes, TOAST tables, and other internal structures that are significantly larger. The 1.33GB backup reflects the actual disk usage of the full PostgreSQL data directory on the volume, which you can confirm by checking the volume's used size in the service settings.

ashlinr
PROOP

a month ago

I have checked whole volume size and it's only 260mb


Status changed to Open Railway about 1 month ago


domehane
FREE

a month ago

Hello

the dashboard backup captures the whole volume not just your database. try pg_dump instead it will back up only your actual data and will be much closer to your 80mb:

pg_dump $DATABASE_URL > backup.sql

Hope this help you :)


domehane

Hello the dashboard backup captures the whole volume not just your database. try pg\_dump instead it will back up only your actual data and will be much closer to your 80mb: pg\_dump $DATABASE\_URL > backup.sql Hope this help you :)

ashlinr
PROOP

a month ago

It's not the backup I'm concerned about so as much as using up storage with backups that are bloated for some reason. I have other projects with much larger databases which backup without this bloat. I don't know why this particular project's postgres volume backup is so large. I could drop the volume and recreate to see if that fixes but want to first check if others have had similar issues. 1.3GB for a 80mb db and 260mb total volume seems wrong to me.

I did restore a backup to the volume (multiple times) and wonder whether that somehow created a false set of data that is being backed up? But then why is the volume still smallish?


ashlinr

It's not the backup I'm concerned about so as much as using up storage with backups that are bloated for some reason. I have other projects with much larger databases which backup without this bloat. I don't know why this particular project's postgres volume backup is so large. I could drop the volume and recreate to see if that fixes but want to first check if others have had similar issues. 1.3GB for a 80mb db and 260mb total volume seems wrong to me. I did restore a backup to the volume (multiple times) and wonder whether that somehow created a false set of data that is being backed up? But then why is the volume still smallish?

domehane
FREE

a month ago

the 260mb in railway's volume metrics might not reflect the actual on-disk postgres footprint , postgres keeps WAL files, transaction logs and other internal data beyond your actual tables. try running this inside your container to see what's really on disk:

du -sh /var/lib/postgresql/data/pgdata/

that real number might explain the gap


domehane

the 260mb in railway's volume metrics might not reflect the actual on-disk postgres footprint , postgres keeps WAL files, transaction logs and other internal data beyond your actual tables. try running this inside your container to see what's really on disk: `du -sh /var/lib/postgresql/data/pgdata/` that real number might explain the gap

ashlinr
PROOP

a month ago

Thanks, but that says 281 MB so still doesn't explain where the 1.33GB is coming from.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...