2021-11-01

LFTP - to mirror file systems - bidirectional - delete optional

I had this working just the other day.  It was a research-only script, because it relies on the security-sketchy "ftp" service.  Nevertheless, very cool. 

Flag Linux FTP file system mirroring 

#!/usr/bin/bash
HOST="10.10.11.17"
USER="backup"
PASS="PASSWORD"
FTPURL="ftp://$USER:$PASS@$HOST"
LCD="/lv1/pictures"
RCD="/lv2/pictures"
#DELETE="--delete"
lftp -c "set ftp:list-options -a;
open '$FTPURL';
lcd $LCD;
cd $RCD;
# reverse means upload
 mirror -c \
       $DELETE \
       --verbose \
       --exclude-glob a-dir-to-exclude/ \
       --exclude-glob a-file-to-exclude \
       --exclude-glob a-file-group-to-exclude* \
       --exclude-glob other-files-to-exclude"
lftp -c "set ftp:list-options -a;
open '$FTPURL';
lcd $LCD;
cd $RCD;
# reverse means upload
 mirror -c --reverse \
       $DELETE \
       --verbose \
       --exclude-glob a-dir-to-exclude/ \
       --exclude-glob a-file-to-exclude \
       --exclude-glob a-file-group-to-exclude* \
       --exclude-glob other-files-to-exclude"

No comments:

Post a Comment

Linux NetworkManager command line configuration

 Configure Network Settings Using Network Manager in Linux Last updated: March 25, 2025 Written by:baeldung Network ConfigurationNetworkMana...