This page looks best with JavaScript enabled

Filezilla is replaced by lftp for the transfer of the local blog to the web server via ftp

 ·  ☕ 2 min read  ·  🤖 SWU

I write my blog locally with the help of hugo and if I want to upload to my web server, I previously had Filezilla used for it.

You can get Filezilla to only transfer changes, it then also shows the differences. Hugo, however, is CLI-oriented and then I would also like to carry out the upload in the terminal.

Since a whole series of new files are generated with a new post after the regeneration of public, not all files have to be transferred again. That would be a job for a suitable tool. So once I went looking. curlftpfs would have been a great candidate together with rsync, but unfortunately there is a memory access error and I can’t use it. Then I found lftp and after a short search to find out how it ticks, I put together a script and I have to say that this tool works like Rsync. If you e. g. have no changes locally, it checks the situation on the ftp server and then exits.

The shell script hugosync.sh

#!/bin/sh
# Requires: lftp

# Configuration:
LOCAL = "/home/user/hugo/blog/public/"
LOGDIR = "/home/user/hugo"
LOGFILE = "lftp.`date + '% Y-% m-% d-% H-% M'`"
ftp_HOST = "ftp.youserver.de"
ftp_USER = "yourserveruser"
ftp_PASS = "yourserverpass"
ftp_SUBFOLDER = "/"

# Execution:
lftp -f "
set ssl-allow true
set passive-mode yes
set ssl:verify-certificate false
open $ftp_HOST
user $ftp_USER $ftp_PASS
mirror --reverse --parallel=4 --log=$LOGDIR/$LOGFILE.log $LOCAL $ftp_SUBFOLDER
bye
"

If you want to use this too, adapt the configuration section to your data. The LOGDIR variable does not have a slash at the end because it is combined with the LOGFILE variable. Also have a look at the man page, there are many more options that can be set.


wüsti
WRITTEN BY
SWU
human