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.
To Backup you website root directory, navigate to the webserver folder, this is often located at one of these locations:
/var/www/html
Default Apache configuration./opt/bitnami/apache2/htdocs
Bitnami LAMP images./opt/bitnami/apps/wordpress
Bitnami application images, replace wordpress with application name (Old approach)./opt/bitnami/wordpress
Bitnami application images, replace wordpress with application name (New approach).
Once inside the root folder you can use the zip command to compress the all files and folders using the following command:
|
|
This method will output a zip file with a backup of all your website assets. To download the file access www.yoursite.com/backup.zip
or use an SFTP client like FileZilla to download the zip file to your local storage.
Certain configurations like Bitnami images use symlinks in the root directory to reach other directories in other paths, take the following example:
|
|
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:
|
|
Now when you try to unzip this folder it will have the symlinks or shortcuts as-is with no modification.
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:
|
|