using wget to replicate a shared ftp folder

I was looking for a simple way to replicate a shared ftp folder to another machine. The replication must be done periodically via cron and it must have a way to resume in case it was interrupted.

The shared folder has the following characteristics:

  • user authentication is required when copying
  • files when uploaded are not changed/updated
  • filenames are unique and may have a directory structure

The above-mentioned requirements are simple so I though maybe I can use wget for this, it has a resume option and it also has an optional authentication method… so maybe it can work.

After some series of trials and errors, I got it working… here’s the code snippet:

#!/bin/bash

user=’ftp user name here’
pass=’ftp password here’

wget –timeout=30 -nH -qrc –level=20 –user=”$user” –password=”$pass” \
ftp://host.here/dir_to_copy/ –directory-prefix=”$HOME”

rsync may have a better approach, but this one worked for me and I’m quite lazy, so why bother…

One thought on “using wget to replicate a shared ftp folder

  1. Pingback: how to: using lftp to mirror an ftp site « mundane idiosyncrasies

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s