Transfer files from a specific directory using wget via SSH

If you want to transfer files from one server to another in less than a few minutes or in seconds (1GB file or lower), then use wget via SSH. I’ve been using this since I was born and I would like to share it to everyone who’s not using it yet. You can transfer a zip files or many files in one directory level, or the entire directory and its sub directories.
The image above is a screenshot of how fast I downloaded the files from a remote server to my new server. 4.5GB in 7 minutes! Not bad huh?

This guide is for those who have experience in using SSH already. Below is an example of how to transfer files in a specific folder from one server to another server.

Transfer all the files that are in folderfour for the url

wget -r -np -nH –cut-dirs=3 -R index.html

(-r) – It will download all files and subfolders in the directory recursively
(-np) – Don’t go to the upper directory. Only the directory you’re in.
(-nH –cut-dirs=3) – Don’t save files to the host name folder but to folderfour by omitting first 3 folders.
(-R index.html) – excluding index.html files.

If you want to just copy all inside the folder without conditions, just use this method.

wget -r

Then you’re done!

Leave a Reply

Your email address will not be published. Required fields are marked *