Server to Server file transfer using FTP via CLI (command line interface)

Note: for this type of operation SSH access is required.

FTP file transfer via command line could be very useful when dealing the the migration for large websites. Due to the amount of files it could be faster to move files server to server instead of downloading the files to your local machine and then uploading the files to the new server.

Follow this steps to migrate files from an old server (IP: 1.1.1.1 ) to a new server (IP: 2.2.2.2):

1- Connect to your new server via ssh as root user
2- Go to the path where you want to download your files. Example: cd /home/username/public_html
3- Connect to the old server FTP account using the following commands:

# FTP
ftp> open 1.1.1.1

In the above example, you'd substitute 1.1.1.1 for the name of your domain or it's IP address you're wanting to connect.

Once connected, a username and password prompt will appear. Once these credentials have been entered, the server allows you to browse, send, or receive files depending on your rights.

4- List your current folder content using command:

ftp> ls
This command prints the names of the files and subdirectories in the current directory on the remote computer. You should find a folder called public_html. Inside this folder you will find files related to your website.

5- Go to directory public_html using command:

ftp> cd public_html

6- From this you can use the following commands to download files from the old server to your new server.

 ftp> get index.php
Downloads the file index.php from the remote computer to the new server. Warning: If there already is file with the same name it will be overwritten.

 ftp> put index.php
Uploads the file index.php from the new server to the old server. Warning: If there already is file with the same name it will be overwritten.

 ftp> mget *.jpg
With mget you can download multiple images. This command downloads all files that end with ".jgp".

 ftp> mput *.jpg
Uploads all files that end with ".jgp".

 ftp> mdelete *.jpg
Deletes all files that end with ".jgp".

 ftp> prompt
Turns iteractive mode on or off so that commands on multiple files are executed without user confirmation.

 ftp> quit
Exits the ftp program.
  • FTP
  • 67 Users Found This Useful
Was this answer helpful?

Related Articles

How to connect to my FTP using FileZilla?

FileZilla is one of the most commonly used FTP clients thanks to its rich-featured and...

Where should I upload the website files?

The document root for your main domain name in a cPanel account is your public_html folder. This...