Lftp reverse mirror silently skips files in subfolders

mirrormirroringrecursive

I'm using lftp to push content to an ftp-only web-server. It worked to upload the files recursively at first, and even incrementally.

Any idea why this would skip files changed in a subfolder, but not skip files changed in the home directory?

Details:
I'm using the reverse mirror mode, which pushes local data up to the server instead of downloading it from the server. Throughout the web, this is the recommended option for recursive upgrade.

Here's the full script (from this answer)

#!/bin/bash    
HOST="..."
USER="..."
PASS="..."
FTPURL="ftp://$USER:$PASS@$HOST"
LCD="/local/directory"
#RCD=""
#RCDCMD=cd $RCD;
#DELETE="--delete"
lftp -c "set ftp:ssl-allow no;
set ftp:list-options -a;
open '$FTPURL';
lcd $LCD;
$RCDCMD \
mirror --reverse \
   $DELETE \
   --verbose \
   --exclude-glob .*swp \
   --exclude-glob .*swn \
   --exclude-glob .*swo"

The related question, was solved by permission issues, which is not an issue in this case. Everything is "rwxr-xr-x" on the server.

Further Testing:
The lftp seems to work intermittently. For example, I will run the command twice, and it skips the changes, then the third time it works, correctly copying the changed files up to the server.

Best Answer

Within the lftp command, run an ls -R before the mirror.

# Set variables as in the question
lftp -c "set ftp:ssl-allow no;
set ftp:list-options -a;
open '$FTPURL';
lcd $LCD;
ls -R;   # This is the key line!
$RCDCMD \
mirror --reverse \
   $DELETE \
   --verbose \
   --exclude-glob .*swp \
   --exclude-glob .*swn \
   --exclude-glob .*swo"

I'm going to continue testing, but this has worked every time I've tested it so far...