Knowledge Base
MilesWeb / How-Tos

Learn how to backup a file before editing it

Approx. read time : 3 min

In this knowledge base post, we will see how to backup a file from the cPanel File Manager, over FTP, or via SSH on a VPS or a dedicated server.

Backup a file in cPanel File Manager

Using the steps updated below, you can simply back up a file by using the cPanel File Manager.

Step 1: Login to your cPanel.

Click on file manager

Step 2: Under the Files section, click on File Manager.

Click on file manager settings

Step 3: In the top right-hand corner, click on Settings. Select the Document Root for – option, and choose your domain from the drop-down.

Step 4: Make sure that Show Hidden Files is selected.

Step 5: Then click Save.

Step 6: Right-click on the file you would like to backup and select Copy from the drop-down.

Type in the name and confirm the path of the file to copy

Step 7: Copy the full path from the Type the path you wish to copy field, for example, this would be:

copy-window

In the field below that with the house icon, paste the full path you copied and then append -BAK to the end. For example, this should look like:

Finally, click on Copy File(s)

confirm-backup

Step 8: Now you should have a backed up copy of your original file, and you can reverse the same steps if you’d like to have your config.php-BAK file copied over the config.php file to restore the data that you have backed up.

Backup a file in FTP client

Below updated are the steps that you can simply use with FTP client to retrieve a local copy of a file for backup purposes. Then you can simply re-upload that backed up file to the server if something goes wrong with the original file.

Step 1: In your FTP client, navigate to the file you would like to backup in the right-hand server pane, in the left-hand pane, navigate to a local folder on your computer you would like to backup your file to.

Step 2: Drag over your file from the right-hand server pane over to your local folder on the left.

filezilla-drag-file-to-local-folder

Step 3: If you wanted to restore the file you have backed up, simply reverse the process and drag the backed up file from your local folder on the left to the remote server directory on the right.

filezilla-drag-file-to-remote-server

Step 4: Your FTP client will present you with a Target file already exists pop-up, simply choose Overwrite as the Action, and then click on OK.

filezilla-confirm-overwrite-file

Backup a file via SSH

To follow these steps, you will need to have SSH access to your server.

Step 1: Login to your server via SSH.

Step 2: Here are 3 example commands you could use to backup the file /home/userna5/public_html/admin/config.php to the same directory as config.php-BAK:

Once you are done, you can see the backed up file:

After taking a look at these steps, we hope that now you can backup a file on your server using a few different methods. This will help you to make sure that you always have a good file if you need to revert back in case you encounter any problem after editing the original file.

Related: Learn how to Backup or Export the Database from SSH.

Avatar
Pravin is Journalist Specializing in Blogging, Social Networking and Community Management. As a constant learner, he is always aiming towards new ideas and greater knowledge. When he is not doing research, reading, or writing for blogs, you can find him hanging around social media sites.