09 | 07 | 2010

With the addition of USB Disk storage to many of our routers, they can now function as a remote backup server with little setup required. The following guide illustrates how to remotely mirror files or folders from a Linux Server to a Draytek router with an attached USB Hard Drive.

First we need to setup the FTP server on the Draytek router with a Username and Password as well as a home folder.

ftp backup application note

 

Now that we have created a user account with the appropriate access we will be using a program called lftp which is installed by default on many Linux Distros, but can be obtained through a repository if needed.

The lftp command we will be issuing is:

/usr/bin/lftp -u Draytek,!Password01 -e "mirror --reverse --delete --only-newer --verbose /Draytek /" ftp.foo.com

Broken down the command is as follows:

/usr/bin/lftp Location of the lftp binary
-u Draytek,!Password01

Username/Password declaration

-e Execute the following commands
mirror Tells lftp we want to mirror
--reverse Tells lftp we want to reverse mirror, i.e. upload to the remote site instead of download from
--delete Tells lftp to delete files from the remote site if they no longer exist locally, thus maintaining a proper 1:1 mirror
--only-newer Tells lftp to only upload files that have changed, shortening the mirror process
/Draytek / Tells lftp to mirror the files located in /Draytek to the / or root of the remote host
ftp.foo.com Tells lftp what host to connect to
You can now input the command into a shell script or directly into crontab.