Syntax for using lftp to synchronize a local folder with an ftp folder?

I would like to sync two folders with each other. It should go in two ways, always keeping the folders up to date (I use the usual cronjob). However, at first I do not get a two-way file transfer to work (it just loads from ftp, and not vice versa).

Secondly, it downloads all content from ftp, even though the registration information has been set to ftp, so access is limited only to a specific folder. Why??

Here is the code (thanks in advance!):

#!/bin/bash

#get username and password
USER=username
PASS=password

HOST="myftpserver.com/users/user1/" #here I have tried with only specifying server name as well as including whole path
LCD="~/Desktop/localfolder/"
RCD="users/user1/"

lftp -c "set ftp:list-options -a;
open ftp://$USER:$PASS@$HOST; 
lcd $LCD;
mirror -c --reverse --verbose $LCD $RCD" #I have tried a few different options w/o result
+3
source share
1 answer

You probably don't need it anymore (4 years late), but I'm just updating it, and if someone comes here with the same problem, ask for help.

FTP- , -

#!/bin/bash

#get username and password
USER=username                   #Your username
PASS=password                   #Your password
HOST="myftpserver.com"          #Keep just the address
LCD="~/Desktop/localfolder"     #Your local directory
RCD="/users/user"               #FTP server directory

lftp -f "
open $HOST
user $USER $PASS
lcd $LCD
mirror --continue --reverse --delete --verbose $LCD $RCD
bye
" 

FTP-, -reverse mirror.

#!/bin/bash

#get username and password
USER=username                   #Your username
PASS=password                   #Your password
HOST="myftpserver.com"          #Keep just the address
LCD="~/Desktop/localfolder"     #Your local directory
RCD="/users/user"               #FTP server directory

lftp -f "
open $HOST
user $USER $PASS
lcd $LCD
mirror --continue --delete --verbose $RCD $LCD
bye
" 

- , , lftp, -, , script .

+4

All Articles