Extracting Compressed Files from the Command Line

Spend enough time on the command line and your bound to memorize a few common commands like zip -r backup.zip wp-content/ and unzip backup.zip. Compressing files and extracting them is a very common task. If it was just the zip format you needed to deal with then the two commands mentioned above will get you quite far. That said there are so many compressed formats, each with their own tools for compressing and extracting, it’s difficult to remember them all. This will be a definitive guide for handling common and uncommon formats as it relates to WordPress.

.zip files – Zip format

# Creates zip file
zip -r filename.zip wp-content/

# Extracts zip file
unzip filename.zip

.tar files – Tar format

# Creates tar file
tar -cvf backup.tar wp-content/

# Extracts tar file, also various other file types like .bz2 and .xz
tar -xvf backup.tar
tar -xvf backup.bz2
tar -xvf backup.xz

.tar.gz files – Tar & Gzip format

# Creates tar.gz file
tar -czvf backup.tar.gz wp-content/

# Extracts tar.gz file
tar -xvzf backup.tar.gz

.gz files – Gzip format

# Extracts gz file
gzip -d backup.gz

.wpress files – All-in-One WP Migration format

This is an open-source format created by ServMask, author of All-in-One WP Migration. It’s a TAR format but extended to support files from any OS and in any locale (Chinese, Japanese, Arabic, etc). The official extraction application, Traktor, can be downloaded here: https://traktor.wp-migration.com.

The Linux version of Traktor requires FUSE. If your using WSL, you’ll need to upgrade to the new WSLv2 for fuse support however that still seems to have some bugs. Instead, for WSL I recommend using a community written Go library called Wpress-Extractor.

mkdir -p ~/Scripts
cd ~/Scripts
git clone git@github.com:fifthsegment/Wpress-Extractor.git
cd Wpress-Extractor/
go build wpress-extractor.go
chmod +x wpress-extractor
sudo mv wpress-extractor /usr/bin/

With that complied and installed you can now extract .wpress files like this.

 wpress-extractor backup.wpress