<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Apache on ElastiCourse</title><link>https://www.elasticourse.com/tags/apache/</link><description>Recent content in Apache on ElastiCourse</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>ElastiCourse.</copyright><lastBuildDate>Sat, 24 Aug 2024 04:09:50 -0400</lastBuildDate><atom:link href="https://www.elasticourse.com/tags/apache/index.xml" rel="self" type="application/rss+xml"/><item><title>How to compress your website htdocs folder into a ZIP file for backup and migrations</title><link>https://www.elasticourse.com/how-to-compress-your-website-htdocs-folder-into-a-zip-file-for-backup-and-migrations/</link><pubDate>Sun, 13 Sep 2020 00:03:35 +0000</pubDate><guid>https://www.elasticourse.com/how-to-compress-your-website-htdocs-folder-into-a-zip-file-for-backup-and-migrations/</guid><description>&lt;img src="https://www.elasticourse.com/how-to-compress-your-website-htdocs-folder-into-a-zip-file-for-backup-and-migrations/targz-linux.webp" alt="Featured image of post How to compress your website htdocs folder into a ZIP file for backup and migrations" />&lt;p>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 goes wrong. Backing up your website root directory (In Apache setups its called htdocs) into a zip file will make it easy to do so.&lt;/p>
&lt;p>To Backup you website root directory, navigate to the webserver folder, this is often located at one of these locations:&lt;/p>
&lt;ul>
&lt;li>&lt;code>/var/www/html&lt;/code> Default Apache configuration.&lt;/li>
&lt;li>&lt;code>/opt/bitnami/apache2/htdocs&lt;/code> Bitnami LAMP images.&lt;/li>
&lt;li>&lt;code>/opt/bitnami/apps/wordpress&lt;/code> Bitnami application images, replace wordpress with application name (Old approach).&lt;/li>
&lt;li>&lt;code>/opt/bitnami/wordpress&lt;/code> Bitnami application images, replace wordpress with application name (New approach).&lt;/li>
&lt;/ul>
&lt;p>Once inside the root folder you can use the zip command to compress the all files and folders using the following command:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">zip -r backup.zip *
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>This method will output a zip file with a backup of all your website assets. To download the file access &lt;code>www.yoursite.com/backup.zip&lt;/code> or use an SFTP client like FileZilla to download the zip file to your local storage.&lt;/p>
&lt;p>Certain configurations like Bitnami images use symlinks in the root directory to reach other directories in other paths, take the following example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">lrwxrwxrwx &lt;span class="m">1&lt;/span> bitnami bitnami &lt;span class="m">29&lt;/span> Jul &lt;span class="m">18&lt;/span> 00:10 wp-content -&amp;gt; /bitnami/wordpress
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">lrwxrwxrwx &lt;span class="m">1&lt;/span> bitnami daemon &lt;span class="m">32&lt;/span> Jul &lt;span class="m">7&lt;/span> 15:59 wp-config.php -&amp;gt; /bitnami/wordpress/wp-config.php
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>When running zip commands in a folder with symlinks, it will automatically copy the destination file/folder to your directory, which leads to a variety of 404 errors and server issues reaching files added to the destination folder post migration. To zip files and respect original symlinks use this syntax instead:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">sudo zip -r backup.zip * --symlinks
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Now when you try to unzip this folder it will have the symlinks or shortcuts as-is with no modification.&lt;/p>
&lt;p>To Unzip the zip file into local development environment or to a new server, upload the zip file to the new web server root directory, the use this command:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">unzip backup.zip
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item></channel></rss>