How to zip a Directory using SSH with htaccess files included

If you’re like me, and work with websites made of thousands of files, whether it was php files, image files or just any file, then you already know that downloading those files through FTP can be a pain, and will eventually take a lot of time.

The easiest way to backup, migrate or move a lot of files at once, is to assemble them in one package, and zip them using SSH, then download the zip file, or use wget to transfer it on another server (Will talk about wget in my next post).

Once logged in using SSH, browse the directory you want to zip, using the cd command, for example:

cd public_html/mywebsite 

Then to zip the entire directory and files recursively, we use:

zip -r filename.zip

To zip all the directories and files with htaccess included, use the following command:

zip -r filename.zip * .htaccess

To unzip the filename that we already zipped, simply use the below command:

unzip filename.zip

Moving or downloading files from a server, can take a lot of time. By zipping all the files and downloading the .zip file, the required download time can be greatly reduced and eventually the files will be received faster.

Leave a Reply

Your email address will not be published. Required fields are marked *