BlueGit

timfa 66wiki

CI: deploy with in-place lftp mirror --delete instead of rm -r

The old job deleted the whole live folder before re-uploading, so the site
was down for the ~10 minutes of every deploy. Now:
mkdir -p -f target; mirror -R --delete --parallel=4 with xfer:use-temp-file
(atomic per-file replace) and cmd:fail-exit (job fails on mirror errors).
No --only-newer/--ignore-time: size+time comparison with a fresh checkout
re-uploads every file, so changes are never skipped.

timfa Tim Falken · pushed by timfa

Authored 2026-09-28 · 7 weeks ago

Hash
f468d5c36b4aac3e81c2a06c48d9d790779b5949
Parent
3ebafbdb
1 file changed +7 −1
.gitlab-ci.yml +7 −1
@@ -113,7 +113,13 @@ ftp_upload:
113 113 script:
114 114 - apt-get update -qy
115 115 - apt-get install -y lftp
116 - lftp -u $timftpuser,$timftppassword $timftphost -e "set ssl:verify-certificate no; set sftp:auto-confirm yes; rm -r $projectftp; mirror -R web $projectftp"
116 # In-place sync instead of "rm -r + mirror": live folders never disappear during a deploy.
117 # - no --only-newer/--ignore-time: the fresh CI checkout gives every file a new mtime, so the
118 # default size+time comparison re-uploads all files (correct even if FTP mtimes are unreliable)
119 # - --delete removes remote files that no longer exist in web/ (runs after the transfers)
120 # - xfer:use-temp-file uploads to a temp name and renames, so a file is never served half-written
121 # - cmd:fail-exit makes the job fail if the mirror fails
122 - lftp -u $timftpuser,$timftppassword $timftphost -e "set ssl:verify-certificate no; set sftp:auto-confirm yes; set xfer:use-temp-file yes; mkdir -p -f $projectftp; set cmd:fail-exit yes; mirror -R --delete --parallel=4 web $projectftp; quit"
117 123 artifacts:
118 124 paths:
119 125 - web
@@ -113,7 +113,13 @@ ftp_upload:
113 script:
113 script:
114 - apt-get update -qy
114 - apt-get update -qy
115 - apt-get install -y lftp
115 - apt-get install -y lftp
116 - lftp -u $timftpuser,$timftppassword $timftphost -e "set ssl:verify-certificate no; set sftp:auto-confirm yes; rm -r $projectftp; mirror -R web $projectftp"
116 # In-place sync instead of "rm -r + mirror": live folders never disappear during a deploy.
117 # - no --only-newer/--ignore-time: the fresh CI checkout gives every file a new mtime, so the
118 # default size+time comparison re-uploads all files (correct even if FTP mtimes are unreliable)
119 # - --delete removes remote files that no longer exist in web/ (runs after the transfers)
120 # - xfer:use-temp-file uploads to a temp name and renames, so a file is never served half-written
121 # - cmd:fail-exit makes the job fail if the mirror fails
122 - lftp -u $timftpuser,$timftppassword $timftphost -e "set ssl:verify-certificate no; set sftp:auto-confirm yes; set xfer:use-temp-file yes; mkdir -p -f $projectftp; set cmd:fail-exit yes; mirror -R --delete --parallel=4 web $projectftp; quit"
117 artifacts:
123 artifacts:
118 paths:
124 paths:
119 - web
125 - web