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

Script to see network interface connection speed

cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1   network-speed ...