Github Enterpriseでお世話になりがちなbackup-utils。
現象
Jenkins上で実施していたら、先日以下のようなエラー。
Backing up GitHub Pages ...
Backing up storage data ...
Backing up custom Git hooks ...
Backing up Elasticsearch indices ...
Pruning 1 failed snapshot(s) ...
touch: cannot touch '<path>/workspace/ghebackup/backup/20200101T000000/incomplete': Permission denied
Makefile:3: recipe for target 'backup' failed
make: *** [backup] Error 1
Build step 'Execute shell' marked build as failure
バックアップ自体は成功しているっぽいのに。
解決策
<path>/workspace/ghebackup/backup/20200101T000000/incomplete
のファイルを削除して再度実行。
原因
2020/1/1のバックアップが別要因で失敗していた。その要因は既に取り除いた。
その際に、<path>/workspace/ghebackup/backup/20200101T000000/incomplete
が吐き出される。このファイルはroot所有になっていた。
以下の実装の通り、どうも他の日付のincomplete
が残っていても今回のバックアップをエラーとしてしまう様子。
(コードはhttps://github.com/github/backup-utils/blob/v2.19.2/share/github-backup-utils/ghe-prune-snapshots#L24-L30より。githubコードの埋め込みはできないみたい)
prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)"
prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l)
if [ $prune_num -gt 0 ]; then
echo Pruning $prune_num "failed snapshot(s) ..."
echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot
fi