In this article I'm going to teach you how to use the lftp mirror command in order to copy your website files from another web host to your VPS (Virtual Private Server) or dedicated server with InMotion Hosting.

The Linux lftp command is a sophisticated FTP/HTTP client that is also capable of being able to mirror the entire contents of a remote website to your local server, or vice-versa. Using the lftp command on your server can help save you time when copying website files from a remote server.

You can directly transfer the files right to your server, instead of having to first locally copy files to your desktop, just to upload them again to your server. Typically web hosts will have higher bandwidth connections than your residential Internet connection, so directly transferring files between two servers with lftp is an ideal method to use if you've got a lot of files to transfer.

In order to follow along with the steps below you'll need to have either a VPS or dedicated server so that you have SSH access to your server in order to run the lftp mirror command.

lftp mirror remote files to your server

Using the steps below I'll show you how to quickly connect to a remote server where you might have website files stored, and then mirror the entire contents of that website to your server using the lftp mirror commands.

  1. Login to your server via SSH with the cPanel user you'd like to copy remote files to.
  2. After logging into SSH run the following command to get to your public directory:

    cd ./public_html/

    You can now run the following command to ensure you're in the right directory:

    pwd

    You should get back something like this:

    /home/userna5/public_html

    In most cases your /public_html/ directory should be empty if you haven't placed any files on the server yet. If you wanted to do your file transfer to another directory such as a sub-directory, you would want to use the cd command again to end up in that directory.

  3. In this example we're going to connect to our old remote server at example.com using the FTP username userna5 and the password of passWORD. Run the following command to begin our lftp session to this remote server:

    lftp -u userna5,passWORD example.com

    If your FTP password includes special characters such as $ or ) you'd want to leave off the password like this, then type it in manually when prompted:

    lftp -u userna5 example.com

    In some cases certain servers will now allow you to connect with lftp with the default settings, you can try the following to connect to these type of servers:

    lftp -u userna5,passWORD example.com -e "set ftp:ssl-allow off"

    You should end up at the lftp prompt when you've successfully connected to the remote server, it would look like this:

    lftp userna5@example.com:~>

  4. Now that you have a FTP connection established to the remote server, the next step is to change directories into the remote directory with your files. To view all of the folders on the remote server you can use the following command:

    ls

    It should give you back something similar to this:

    lrwxrwxrwx 1 userna5 userna5 33 Jul 16 2011 access-logs -> /usr/local/apache/domlogs/userna5
    drwxr-xr-x 2 userna5 userna5 4096 Nov 20 2010 backup
    drwxr-x--- 4 userna5 12 4096 Jan 28 14:14 etc
    drwxr-x--x 11 userna5 userna5 20480 Jan 10 12:52 mail
    drwxr-x--- 11 userna5 99 4096 Jan 28 14:15 public_html
    drwxr-xr-x 10 userna5 userna5 4096 Jan 22 13:56 tmp
    lrwxrwxrwx 1 userna5 userna5 11 Jul 16 2011 www -> public_html

    In this case our website files are stored in the /public_html/ directory so we can run the following command to get to this directory:

    cd public_html

  5. Now that you've changed into the remote directory where you'd like to mirror all of the files to your server from, run the following command to begin the file transfer:

    mirror -c

    This uses the lftp mirror command to mirror the entire remote directory to our current local directory that we changed to prior to starting the transfer. The -c option is for continue and allows the mirror to continue from a previously failed transfer.

    After the file transfer has completed you should see the status of the full transfer which looks something like this:

    lftp userna5@example.com:/public_html> mirror -c
    Total: 175 directories, 1316 files, 0 symlinks
    New: 1316 files, 0 symlinks
    20750001 bytes transferred in 20 seconds (1010.8K/s)
    To be removed: 1 directory, 0 files, 0 symlinks

  6. Type either exit or quit to leave the lftp session:

    lftp userna5@example.com:/public_html> exit

You should now know how to use the lftp mirror command on your VPS or dedicated server in order to transfer over website files from a remote server.

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
n/a Points
2014-10-16 1:04 am

It seems like these instructions desribe going to the old server and copying the files. How do you then go to the new server and point them in the right location to be copied?

Staff
19,412 Points
2014-10-16 7:24 am
Hello Jay,

That is taken care of in Step 2. When you log in, run pwd to see where you are. If you are not in the place you want to be, simply change directories (using the cd command) until you are in the desired directory. Then when the lftp runs it pulls the files to the proper directory.

Kindest Regards,
Scott M

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.

3 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!