A host that only speaks FTP

Part 5 of 5 of ./blog.sh v1.9

A shared hosting plan often comes with a directory, an FTP login and nothing else — no SSH, no rsync, no git. That has been enough for blog.sh all along; the docs just never said so until 1.9. The way there is the rclone backend, because rclone speaks FTP as one of its many remotes.

Set up the remote once

rclone config asks its questions once and keeps the answers — the host, the user and the password live in rclone's own config, never in env.sh. Create a new remote, pick the type ftp, and give it the three things the hosting plan's welcome e-mail lists. Then two lines in env.sh:

export DEPLOY_BACKEND=rclone
export RCLONE_TARGET=myftp:public_html   # remote name : the directory the host serves

The part after the colon is whatever directory the host serves as your site — public_html, www, htdocs, depending on the host.

Why nothing else is needed

FTP cannot tell anybody what a file on the server contains; there is no checksum to ask for. A deploy that had to compare the server's copy with the build's would have to download everything first. It never has to: the engine keeps its own record of every file it has sent — the manifest, one per backend — and tells rclone exactly which files to send and which to delete. The first deploy uploads the whole site; every one after that only what changed.

Two things a shared host does

It may offer FTPS. Plain FTP sends the password in the clear. If the host supports FTPS, turn it on in rclone config (explicit_tls), and nothing in the engine changes.

It may allow only a few connections per account. rclone opens several at once by default, and a host with a low limit answers with "too many connections" halfway through the deploy. One more line makes rclone take them one at a time:

export RCLONE_ARGS="--checkers 1 --transfers 1"

rclone also has --ftp-concurrency, but its own documentation warns that it is very likely to deadlock unless it is set to one more than the two flags above together. The two flags are the simpler way to the same limit.

Before the first upload

./blog.sh doctor checks that rclone is installed — and that it is not the snap, which can read only inside your home directory and fails every deploy of a site kept anywhere else. ./blog.sh doctor --online then lists what already stands in public_html that the site does not put there: on a hosting plan that is usually the host's placeholder page or an old site, and the post Before the first deploy says what to do about it.

Comments