zip archive log files using archive_command postgres

In PostgreSQL WAL files are created as 16 MB chunks. Even though there is no transactions written into the WAL files still it occupy 16 MB space. To reduce the space usage, zip those files with archive_command parameter.

Enable archiving with compression of archivelogs:

wal_level=archive # you can set this value to any value after archive
archive_mode = on
archive_command = ‘cp %p /home/postgres/archivedir/%f && gzip /home/postgres/archivedir/%f’

NOTE: replace “/home/postgres/archivedir” with the archive location where you want to store your archive logs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s