Archive

Posts Tagged ‘ftp’

FTP Sync

April 14th, 2010

I use rsync a lot for sync between my Local and Remote Backup Server, rsync is doing very great job in term of speed and stability. But in certain cases, my client is not using ssh enabled account. So i forced to use an FTP sync, which is very slow. Sure you can use usual FTP Client like Filezilla, etc. But I doesn’t have a good build in sync system.

So I start googling and find 1 solution using LFTP. This program is already installed on standard Ubuntu installation, so you can use it immediately.

This is a sample file how to do a sync

#!/bin/bash    
HOST="yourhost.com"
USER="yourusernamehere"
PASS="yourpasswordgoeshere"
LCD="/home/local/directory/"
RCD="/home/remote/directory/"
lftp -c "set ftp:list-options -a;
open ftp://$USER:$PASS@$HOST; 
lcd $LCD;
cd $RCD;
mirror --reverse \
       --delete \
       --verbose \
       --exclude-glob config/ \
       --exclude-glob .htaccess \
       --exclude-glob index.php"

Finally in the section where it writes –exclude-glob, you write file that you should exclude in sync process. You can write directory name with / (slash) or filename, or event support a wildcard (* / ?).

Hope it helps

Share

linux, programming , ,

Switch to our mobile site