How to compress your website htdocs folder into a ZIP file for backup and migrations
- September 13, 2020
- Posted by: ElastiCourse
- Category: How-To Linux
Backing up your website periodically is a very important procedure to ensure stability and ability to roll back your site to a previous snapshot in case something went wrong. Backing up your website root directory (In Apache setups its called htdocs) into a zip file will make it easy to do so.
To Backup you website root directory, first you need to navigate to the webserver folder, this is often located at one of these locations
/var/www -> Files will be installed in subfolder called "html" /opt/bitnami/apache2 -> For bitnami LAMP images, Files will be installed in subfolder called "htdocs" /opt/bitnami/apps/wordpress -> For bitnami application images, replace wordpress with application name, Files will be installed in subfolder called "htdocs"
Once inside the foler you can use the zip command to compress the folder using the following syntax
zip -r backup.zip htdocs -> Replace htdocs with html or the exact folder name where your website files live
This method will output a zip file with a backup of all your website assets, and will not be available to the public in the same time so you would need to connect to your website using SFTP client like FileZilla to download the zip file to your local storage.