Creating a Backup using the TAR Command Print

  • 5

One of the most common commands you will discover when dealing with a hosting server is the TAR and GZIP commands.  Because these tools are so common, the GZIP compression engine has been tied into the TAR script. This allows you to execute a single command that will package and compress an entire folder tree.

Create Compressed TAR Files for BACKUP

  • Create TAR.GZ in the parent folder containing all contents of the current & child folder:

    tar -czvf ../filename.tar.gz .

  • Create TAR.GZ in the parent folder containing just just JPG images contained in the current & child folder:

    tar -czvf ../filename.tar.gz *.jpg

  • Extract TAR.GZ file contents into current folder:

    tar -xzvf filename.tar.gz

    Create a TAR.GZ file, but Exclude two folders:

    tar -czvf ../filename.tar.gz . --exclude 'FolderA' --exclude 'FolderB'


Was this answer helpful?

« Back