Have u ever waited for hours to transfer a batch of files from a server to a local machine? I know it is annoying. FTP solutions like FileZilla and WinSCP are very useful for transferring few files between remote machine and local machine. But, it takes too much time to transfer a large number of files. This post shows how you can transfer a large number of files from a server to a local machine quickly by zipping files.
- Method 1: Transfer files using FileZilla
- Method 2: Quickly Transfer files using Terminal by gZipping
Method 1: Transfer Files using FileZilla
You can use any FTP client such as FileZilla, or WinSCP for transferring files. FileZilla is available for Windows, Mac, and Linux platforms. Click here to download FileZilla.
Open FileZilla client on your local machine and connect it to the remote machine. Drag and drop files and folders to transfer between server and local machine.
Method 2: Quickly Transfer files using Terminal by gZipping
Login to Server via SSH
I am using Terminal application on Mac for logging to Server. Use
ssh command to get connected to server. If you are on a windows machine, then you can download Putty ssh client for connecting to a server.
sh-3.2 : ssh firstname.lastname@example.org root@website's password:
Perform GZip Compression on contents of a server
gZip is very powerful utility to compress the contents. Gzip files have extension of
tar command on linux servers to achieve gZip compression.
gZip compresses file content and archives them in a single zip file. This single Zip file with reduced size is much faster to transfer from server to local machine. Following command will create a gZip archive file in your server’s current working directory.
email@example.com [~] : tar -czvf name-of-archive-file.tar.gz /path/to/file-or-folder-on-server
- c : indicates to create an archive file
- z : indicates to use and gZip compression
- v : indicates visual of compression progress
- f : indicates to provide an archived filename
Move gZip Archived File from Server to Local Machine
We have archived file ready on server to move on local machine. Switch to putty/terminal on your local machine and run following command to move files from server to local machine.
MacBook-Air:~ hpatel$ scp firstname.lastname@example.org:/path/to/file-or-folder-on-server/name-of-archive-file.tar.gz /path/to/local/file
It will ask for password of your remote site login and start moving the specified archived file from server to local machine.
Unzip archive file on local machine
Once the gZipped file is moved to a local machine, you can unzip content on your local machine. This will unzip content on your current working directory.
MacBook-Air:~ hpatel$ tar -zxvf /path/to/local/file/name-of-archive-file.tar.gz
Advanced gZip Options
# Zip multiple direcotry together # Provide multiple directory's with space email@example.com [~] : tar -czvf compressed.tar.gz /path/to/dir1 /path/to/file1.txt /path/to/dir2 # Exclude some directory's from zipping # use --exclude to provide a directory or file to exclude from exclusion firstname.lastname@example.org [~] : tar -czvf compressed.tar.gz /var/logs --exclude=/var/logs/mysql --exclude=/va/logs/tomcat email@example.com [~] : tar -czvf compressed.tar.gz /var/logs --exclude=/var/logs/*.png