How to recursively copy from a ftp server in the Linux command line with just 2 commands or by using the Tcl VFS

Show table of contents

So this is an example when doing some research before you start coding some automation pays off.

Of course I can write my own FTP crawler in Tcl!

But why when it's easier to copy a whole FTP server recursively in just 2 lines!

First install FTPfs (Debian Linux distro assumed)

sudo apt-get install curlftpfs

Let's say we want to make a copy of all the Gutenberg books.. for safekeeping and archiving purpose.


What curlftps does is create a virtual filesystem with a mountpoint to the ftp website. This means we can access it as if we where accesing anyother file on our pc. The true and great power of Linux is thus shown in the following commands:

sudo curlftpfs /mnt/gutenbergftp
sudo cp -Ruv /mnt/gutenbergftp /home/lostone/Gutenberg

Something similair can be done with Tcl using the tcl vfs

The Tcl VFS (Virtual FileSystem) is a ver ypowerful thing which lts you mount many remote filesystems as if they where local:

  • http
  • ftp
  • tar files
  • webdav
  • zip files
  • And many others with extra extensions like ssh, LZW, delta virtual filesystems, etc..

Think of the folowing example ftp:

    package require vfs::urltype
    vfs::urltype::Mount ftp
    file copy .
    file copy .

You can find out more at: and

Cron jobs

Of course you can also set a cron job to update data once in a while.. But test everything out before writing any cronjob, ok?

curlftpfs /mnt/backup

Then set this to cron: cp -R -n /i/wanna/backup/this /mnt/backup/ > /dev/null

Subscribe to my newsletter

NOTE:You will need to confirm your e-mail address in order to fully complete the subscription process.

What are your thoughts?

All comments are moderated and must adhere to the terms of service.

You might enjoy these similar articles: