Sometimes you need to move a website from one server to another. Instead of downloading the website from the old server to your PC via FTP and uploading it from your PC to the new server, it would save a lot of time to copy the web site from one server to the other. This tutorial explains how to use Wget to download/move a website from one server to the other via FTP.
1 Preliminary Note
I assume you have a working FTP login on the remote server.
The wget command is installed already on many systems. in case it is not installed on your server or desktop yet, use the following commands:
Install wget on Debian and Ubuntu
sudo apt install wget
Install wget on CentOS, AlmaLinux or Rocky Linux
dnf install wget
3 Using Wget
To download a remote web site to your local server recursively, you can use Wget as follows:
wget -m ftp://username:[email protected]/
The -m switch enables mirroring, which means it enables recursion with infinite recursion depth and keeps FTP directory listings and time stamps.
If you want to download a specific subdirectory, e.g. /htdocs, you’d do it as follows:
wget -m ftp://username:[email protected]/htdocs
If your username or password contains spaces or special characters, put them in single quotes. Example:
wget -m ftp://'user name':'email@example.com/