How to download a backup via ssh

Ben Gayson
Published: 17 April 2024Last updated: 17 April 2024
Share:

Why would you need to make a backup in SSH? 

The primary reason for using SSH to back up your website is its speed and simplicity. Backing up your site is especially crucial when you're about to make extensive changes, facing unresolved issues that might require a restoration from a backup, or simply adhering to best practices.

What are the most popular SSH clients?

How do I connect to my site via SSH? 

If you haven't connected to SSH before, we have a guide on how to do this that is available here 

Step 1 - Compress your website.

The first step is relatively simple and that is to zip up the website files, the best way to do this is to zip up the public_html folder. Once you run the command below you will see a zip file of public_html within the root directory. The reason for compressing the web files is it will make it much easier and quicker for you to download the files

zip -r public_html.zip public_html/ 
image.png

Step 2 - Make the files web-accessible.

The next step is to move the zip folder into a folder where it is accessible via the website the majority of the time the document root for your website will be public_html therefore we need to move our zip folder into public_html which we can do with the following command, 

 mv public_html.zip public_html/public_html.zip

Step 3 - Downloading the web files

All that needs to be done to download the files is to visit the site in your browser. In this case, the link would be your normal website URL with public_html.zip appended as if it were an extra link. This will then automatically start the download and all that needs to be done is to wait for this to finish. Once finished you will find you have a backup of your website downloaded onto your local machine.  So for example, if your website is domainname.co.uk then you would need to visit domainname.co.uk/public_html.zip 

Alternative download methods

There are multiple different ways of downloading website backups, the easiest method would be to use the backup restore tool within My20i this allows you to download a backup and you can also upload a zip file to restore if you need to. Other methods include using SFTP/FTP to download the files, WinSCP is also a tool which uses a secure SSH connection to allow you to make a connection to the package to download the files.