Pages

Monday, October 14, 2013

NCftp - get multiple Folders with ftp

    The NcFTP client is a powerful tool for transferring files over FTP, especially useful for system administrators and developers. It offers advanced features like recursive directory downloads, making it a great alternative to standard FTP clients. This guide will walk you through installing NcFTP and using its recursive download capabilities.


    INSTALLING NCFTP

    NcFTP is compatible with various Unix-like operating systems, including FreeBSD, Solaris, and most Linux distributions.

    On Debian/Ubuntu Systems: You can easily install NcFTP using the apt-get package manager. Open your terminal and run the following command:

    sudo apt-get install ncftp
    

    This command will download and install the NcFTP client on your system.


    RECURSIVE DIRECTORY DOWNLOADS WITH NCFTPGET

    ncftpget is a command-line tool within the NcFTP suite designed for efficient file transfers, particularly for scripting and advanced usage. It allows you to download entire directories and their contents recursively.

    Basic Recursive Download Command: To download a remote directory and all its subdirectories and files, use the following format:

    ncftpget -R -v -u "USERNAME" ftp.server.com /local/directory /remote/directory
    

    Let's break down the options:

    • -R: This crucial option tells ncftpget to copy all subdirectories and files recursively from the remote server.

    • -v: Stands for "verbose." This displays detailed download activity and progress in your terminal, which is helpful for monitoring transfers.

    • -u "USERNAME": Specifies the username for logging into the FTP server. If you omit this, ncftpget will attempt to log in anonymously.

    • ftp.server.com: Replace this with the actual hostname or IP address of your FTP server.

    • /local/directory: This is the path on your local machine where you want to save the downloaded files.

    • /remote/directory: This is the path to the directory on the remote FTP server that you wish to copy.

    Example: If you wanted to download the /www-data directory from ftp.nixcraft.net to your local /home/vivek/backup directory, using the username ftpuser, the command would be:

    ncftpget -R -v -u "ftpuser" ftp.nixcraft.net /home/vivek/backup /www-data
    

    TROUBLESHOOTING: "TAR MODE" ERROR

    Sometimes, when performing recursive downloads, you might encounter an error message similar to this:

    tar: End of archive volume 1 reached
    tar: Sorry, unable to determine archive format.
    Could not read directory listing data: Connection reset by peer
    

    This error often indicates that ncftpget is attempting to use "TAR mode" for the recursive transfer, which might not be supported or configured correctly on the FTP server, or it's encountering issues with directory listings.

    Solution: Disable TAR Mode To resolve this, you can add the -T option to your ncftpget command. The -T option explicitly tells ncftpget not to try using TAR mode with recursive mode.

    Revised Command for Error Resolution:

    ncftpget -T -R -v -u "ftpuser" ftp.nixcraft.net /home/vivek/backup /www-data
    

    By adding -T, you ensure that ncftpget uses a different method for recursive downloads, bypassing the TAR mode issue.

No comments:

Post a Comment