I had to figure this out myself and thought I’d share what I’m doing.

Make an archive:
tar -cf TargetFile.tar Foldername/
The c flag tells it to create an archive.
The f flag tells it that you’re making an archive from files.

Compress it:
gzip TargetFile.tar

And the resulting file is:


If you want real good compression and so on, you’ll need to play around with the flags, but this will do when you simply need to transfer quickly. I tested on a big folder of about 250MB, the .tar file was 285MB and the resulting .tar.gz file was 211MB.

3 thoughts on “How to archive or zip a folder with a command line so you can transfer it

  1. I like the following using the -C parameter. This creates relative directories, so if you untar on a different box, you are not forced to untar to the exact same full directory from root.

    (Especially if you do not have permissions to access that dir on the new box! A bit of a neccessity then 🙂 )

    tar cvf $BASE_DIR/mynewtar.tar -C $BASE_DIR online backup 2>dev/null


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