In this article I'm going to go over a few ways in which you can backup a file for your website. That way if you directly modified the original file on the server and made a mistake, you can revert to your saved copy.

Many times you might need to modify a config, include, or template file for your software that you're running on your website. In most cases it is much easier to just directly modify these files instead of editing a local copy and then re-uploading that to the server.

In this article I'll review how you can backup a file from the cPanel File Manager, over FTP, or via SSH if you happen to have a VPS or dedicated server.

Backup a file in cPanel File Manager

Using the steps below I'll show you how you can easily back up a file using the cPanel File Manager.

  1. Login to your cPanel.
  2. Under the Files section, click on File Manager.
  3. Select the Document Root for: option, and choose your domain from the drop-down.
  4. Ensure that Show Hidden Files is selected.
  5. Then click Go.
  6. cpanel click on file manager and go
  7. cpanel file manager right click on file then click copyRight-click on the file you'd like to backup, and select Copy from the drop-down.
  8. cpanel file manager copy page click copy files Copy the full path from the Type the path you wish to copy field, in our example this would be:

    /public_html/admin/config.php

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

    /public_html/admin/config.php-BAK

    Finally click on Copy File(s)
  9. cpanel file manager backed up fileYou should now 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 backed up data.

Backup a file in FTP client

Following the steps below you can also simply use a FTP client to retreive a local copy of a file for backup purposes. Then you can simply re-upload that backed up file to the server in the event that something went wrong with the original file.

  1. In your FTP client navigate to the file you'd like to backup in the right-hand server pane, in the left-hand pane navigate to a local folder on your computer you'd like to backup the file to.
  2. filezilla drag file to local folderDrag over your file from the right-hand server pane over to your local folder on the left.
  3. filezilla drag file to remote serverIf you wanted to restore your backed up file, 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.
  4. filezilla confirm overwrite fileYour FTP client will more than likely present you with a Target file already exists pop-up, simply choose Overwrite as the Action, then click on OK.

Backup a file via SSH

To follow along with the steps below you'll need to have SSH access to either your VPS or dedicated server.

  1. Login to your server via SSH.
  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:

    cp -frp /home/userna5/public_html/admin/config.php{,-BAK}

    cp -frp /home/userna5/public_html/admin/config.php /home/userna5/public_html/admin/config.php-BAK

    cd /home/userna5/public_html/admin/
    cp -frp config.php config.php-BAK

    You should then be able to see the backed up file:

    userna5@server [/home]# ls -l /home/userna5/public_html/admin/
    total 16
    drwxr-xr-x 2 userna5 userna5 4096 Feb 19 14:45 ./
    drwxr-xr-x 3 userna5 userna5 4096 Feb 19 13:59 ../
    -rw-r--r-- 1 userna5 userna5 395 Feb 19 14:34 config.php
    -rw-r--r-- 1 userna5 userna5 395 Feb 19 14:34 config.php-BAK

You should now understand how you can backup a file on your server using a few different methods. This will help ensure that you always have a good file to revert back to incase any problem are encountered after you've edited the original file.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!