How to compress files with xz and upload archive to Google cloud ?

ยท ยท 99 words ยท 1 minute read

First, install Google cloud command line tool and configure it.

  1. pip install gsutil
  2. Have your project id ready using gsutil config. Check docs for more info.

Create the archive / compressed file

  1. tar --create --verbose --xz --file images.tar.xz /directory/containing/images/*

Upload the archive/compressed file to Google cloud

  1. gsutil cp images.tar.xz gs://<bucket name>. replace <bucket name> with your Google cloud bucket name ๐Ÿ˜„.

If you want to extract contents (images in this case) from archive, use this command tar -xf file.tar.xz.

xz is supposed to be the “best” general purpose compression algorithm in terms of compression ratio, but it’s also slow.

Share: