How to create archives using SSH

July 4, 2023 / Security and Backups

In this article, we will explain how to create archives using SSH.

Creating archives is possible using WHUK’s File Manager. To create an archive using SSH,  Follow these simple steps:

Connection:
First of all, you need to enable SSH access and connect to your account using SSH. Now, open the directory, and find out the files and folders, that you want to compress and locate.

  1. Open your website’s root directory.
  2. Run the “ls” command. If the needed content is in a subdirectory, reach it by executing the below command:
    cd path/to/files

    If you want to see the needed files and folders, then you can go to Step 2.

  3. Where “path/to/files” is changed by an actual path to your files.
    For Example: If your files are located in public_html/new/version1, then the command would be

    cd new/version1

Create an archive:

To create an archive, only one command is required. Depending on what you want to compress and the archive format you want to save it in, the command changes:

  1. Archive separate files
    ZIP: zip archive-name.zip filename1.php filename2.php filename3.php
    TAR: tar -cvf archive.tar filename1.php filename2.php filename3.php
    TAR.GZ: tar -zcf NewArchive.tar.gz filename1.php filename2.php filename3.phpHere “archive” should be replaced with the name of your future archive, followed by the files you want to add to the archive.
  2. Archive of the whole directory
    ZIP: zip -r archive.zip DirectoryName
    TAR: tar -cvf archive.tar DirectoryName
    TAR.GZ: tar -zcf archive.tar.gz DirectoryNameAs you can see from the new line, creating an archive takes some time until it is complete.-bash-4.2$

In this way, you can create archives using SSH. For more information, visit our knowledge base section.

Spread the love