Having a local version of a website for development is a necessity. Chances are, you aren’t saving all the uploaded content for your website in your repository and there are many reasons you may need to download the files to your local machine. Perhaps you’re working on a new machine and you’ve checked out a copy of the project. You have a copy of the database with all the posts and pages but you’re missing all the associated files and this can interfere with development in some cases. Or perhaps you haven’t worked on the site in 6 months and the content has changed on the live site in that time and you’d like your local version to match. Or maybe you’re closing down the server but you’d like to download the content so it can be transferred to a new server. The problem you are left with is that your server has files which you don’t have locally. Provided you have SSH access to your server, the solution is simple: you can create a zip folder and transfer it to your local machine with Secure Copy Protocol (SCP). Here’s how:
Connect to the server via SSH:
ssh <user>@<ip address>
Navigate to the location of the folder you’d like to copy. If you don’t have zip installed on your server, assuming it’s running Ubuntu, you can install it with the following command:
apt-get install zip
You can create a zip folder like so:
zip -r <filename.zip> <folder>
We now have our zipped folder. All that remains is to copy it to our local machine with SCP. SCP uses SSH for data transfer and relies on the same authentication methods, so provided you can connect to your server via SSH you should be able to use SCP. You can log out of your SSH connection and navigate to the folder on your local machine that you’d like to save the folder in and type the following command:
scp <user>@<ip>:<path to zipped file> .
You should now find the zipped folder ready for use on your local machine.
PHP 7.4 was released on 28 November 2019 and with it comes a lot of new features. In this post we'll examine a few of the more interesting ones along with examples of how they can be used. PHP has long been the punchline in low-effort memes, and though some of the disdain for the language is justified, more recent… Continue reading »
We're going to create a bash script which runs mysqldump (a MySQL backup program) to generate a database backup with a filename containing the date. We're then going to set up a cron job (a utility for running scheduled tasks) to run the script at regular intervals. We'll do all of this securely so that other users on the server can't… Continue reading »