Skip to content

Instantly share code, notes, and snippets.

@dobrivoje
Last active April 21, 2017 08:59
Show Gist options
  • Save dobrivoje/f6ead0d9efc91c6d62739d5a91a8e5ca to your computer and use it in GitHub Desktop.
Save dobrivoje/f6ead0d9efc91c6d62739d5a91a8e5ca to your computer and use it in GitHub Desktop.
Linux - Multi cpu compression of (large) postgresql database backup(s)
###########################################################
# fast compression of the big postgresql backup file #
# we'll take advantage of the multi processor machine #
# to speedup compression process ! #
# #
# reqirement : apt-get install pigz (ubuntu/debian like) #
###########################################################
# input parameter1 = <entire folder to compress>
# input parameter2 = $CPU_NO
# output parameter = <archive name>.tar.gz - file which will be created
tar -cf <entire folder to compress> | pigz -9 -p <$CPU_NO> > <archive name>.tar.gz
# example :
# tar -cf /tmp/db-public.23122015.backup | pigz -9 -p 16 > /ssd/backups/archives/db-public.23122015.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment