rsync
rsync, for some reason or another, has been removed from my workflow.
openrsync (on OpenBSD) is very limited, and can only replace a subset of uses for rsync, such as to download the RFC, but not without any of the bazillions of symlinks that confuse openrsync. Don't much need those symlinks.
rfcs:
openrsync --delete -rtv ftp.rfc-editor.org::rfcs-text-only rfcs
.PHONY: rfcs
The other major use of rsync involved a virt in the cloud, and as such that virt may or may not be as trustable as those whose remote and physical access is better known. openrsync here deleted all the remote files, then did a sync of all the files, which is perhaps not good? Instead, a git hook was setup since the entire repository is also backed up to the virt, so that on push the site is updated from a local checkout of the backup repository. This is slightly more difficult than an rsync push to get working.
$ cd /var/gemini
$ git clone ~/var/gemini/thrig.me.git new
$ mv thrig.me old
$ mv new thrig.me
$ doas rcctl stop gmid
$ doas rcctl start gmid
$ cat ~/var/gemini/thrig.me.git/hooks/post-receive
#!/bin/sh
while read oldrev newrev refname; do
if [ "$refname" = "refs/heads/master" ]; then
unset GIT_DIR
cd /var/gemini/thrig.me || exit 1
git pull -q
mkdir tmp 2>/dev/null
break
fi
done
exit
$ chmod +x ~/var/gemini/thrig.me.git/hooks/post-receive
$ rm -rf old
The tricky bit was GIT_DIR which until unset fouls up the pull. printf-style debugging via an env(1) call in the script revealed the noxious presence of this environment variable. Another tricky bit is that gmid should probably no longer serve out various git stuff that were previously excluded by the rsync.
location ".git*" {
block return 50 "nope"
}
location "*/.gitignore" {
block return 50 "nope"
}
Be sure to test these things, as the globs can be tricky to get right.
$ gmitool get gemini://thrig.me/.git
gmitool: permanent-failure 50 nope
$ gmitool get gemini://thrig.me/.git/config
gmitool: permanent-failure 50 nope
$ gmitool get gemini://thrig.me/software/assembly/.gitignore
gmitool: permanent-failure 50 nope
Concerning Hooks
git likes to spam the hooks folder with sample scripts, so if you use a lot of git repositories—205 at the moment, not counting third-party clones from elsewhere—it may make sense to delete those files and set a blank hooks directory to try to minimize hook spam. See "TEMPLATE DIRECTORY" in git-init(1) for more details.
thrig$ cat .gitconfig
[init]
defaultBranch = master
templateDir = /var/empty
Do note that on some operating systems the /var/empty directory may not actually be empty. You may need to create your own empty directory on such platforms.
On my laptop there is a non-empty hooks directory as on commit a script is run to log which repositories have been changed so that the "pushall" script can push them off to where they need to go. All the third-party repositories are excluded from this as those are not pushed anywhere. Now that I think about it, there are some third-party repos with a "mods" branch that maybe should be pushed somewhere, but there are also restic backups of this whole mess.
[core]
autocrlf = false
editor = ed
hooksPath = ~/libexec/git-hooks
On the other hand, git like rsync is also huge and complicated and probably should be replaced with something simpler, something more elegant. Maybe Fossil, or to switch back to CVS? CVS ain't much on the elegance front, but does go lighter on the CVE train.