What is File Compression?
File compression is the process of taking several (or many) files and combining them into one, smaller file. This smaller file can then be uncompressed and returned to their separate, regular sized files.
When Should I Use File Compression?
There are various reasons to compress files, but the foremost is that you want to make the file more manageable. By compressing, you make the file size smaller, and, if there are multiple files, they are grouped together. This grouped together file is called an archive file.
If, for example, you wanted to send a few pictures via email to a friend, you might find that the pictures take a long time to send because their file size is so large.
So the natural thing to do would be to make the file size smaller. You can do that by compressing the images.
Likewise, if you wanted to quickly download the contents of a directory on your hosting account (for example, your entire public_html directory), you could create a compressed version of that, then download the entire archive file in one go. That way you don't need to copy multiple files or worry about the transfer size.
What's the difference between .ZIP, and TAR.GZ files?
There are different kinds of compression, so it's important to make sure that you use the best compression method for your situation. Here are some popular ones:
.ZIP
.ZIP is one of the most popular compression methods, known for its quick compression and extraction times. It's suitable for both Windows and Mac users.
TAR.GZ
TAR.GZ is great for Unix users and by extension, Mac users. Many MacOS versions allow you to double-click a TAR.GZ file to extract it. However, if you are a Window's user, you will need additional software to extract a TAR.GZ file.
How to Compress Files in the ACC
The Account Control Center (ACC) in Shared, VPS, and Dedicated accounts allows you to compress files right in the interface. This process does not require any use of the command line.
However, this method does not work on WP Enthusiast or WP Professional accounts.
If you would prefer a method that does not use the command line and you are using a Shared, VPS, or Dedicated account, see our article: How to Take Manual File Backups on Shared, VPS, and Dedicated Accounts
How to Compress Files via the Command Line
Shared VPS Dedicated WP Enthusiast WP Professional WP Professional Plus
You can compress and extract files within your Pair hosting account. To do so, you must first connect to your Pair hosting account via SSH.
Once you have connected, find your desired compression method below, then use their commands to compress and extract files.
Note that these commands will compress and extract the files within the hosting account's file system. If you want to download the files, we recommend you either use SSH or SFTP.
.ZIP Compression and Extraction Commands
To compress or extract with .ZIP files, use the following commands in your command line:
To Compress:
zip -v newfilename.zip file1.ext
Be sure to replace the following from the command:
newfilename | Replace with the name you want the compressed file to be called |
File1.ext | Replace with the file that you want to be compressed |
To Extract:
unzip filename.zip
Be sure to replace the following from the command:
filename.zip | Replace with the name of the compressed tar.gz file you want to extract. Note that this command will not work on other compression types |
TAR.GZ Compression and Extraction Commands
To Compress:
tar -cvzf newfilename.tar.gz file1.ext
Be sure to replace the following from the command:
newfilename | Replace with the name you want the compressed file to be called |
File1.ext | Replace with the file that you want to be compressed |
To Extract:
tar -xvzf filename.tar.gz
Be sure to replace the following from the command:
filename.tar.gz | Replace with the name of the compressed tar.gz file you want to extract. Note that this command will not work on other compression types |