PR #498 changed the redis-persistent backup command to only back up *.rdb files rather than the entire /data directory. The command fails when /data contains no .rdb files.
The uselagoon/redis-7-persistent image sets WORKDIR /data, so the *.rdb glob expands correctly from /data when files are present. However, busybox ash does not support nullglob, so when no .rdb files exist (a fresh Redis pod that has not yet written dump.rdb), the shell passes the literal string *.rdb to tar. Tar then tries to open a file named *.rdb inside /data via the -C path and fails.
This means the first k8up backup of a newly-provisioned Redis persistent service will always fail. After Redis writes its first dump.rdb, subsequent backups succeed.
Reproduction
# Fails: empty /data, no .rdb files
docker run --rm uselagoon/redis-7-persistent \
/bin/sh -c "tar -cf - -C /data --exclude='temp-*.rdb' *.rdb"
# tar: *.rdb: Cannot stat: No such file or directory
# Works once dump.rdb exists
docker run --rm uselagoon/redis-7-persistent \
/bin/sh -c "touch /data/dump.rdb && tar -cf - -C /data --exclude='temp-*.rdb' *.rdb" | tar -t
# dump.rdb
Fix
The simplest approach that stays closest to the original command:
/bin/sh -c "ls /data/*.rdb 2>/dev/null | grep -q . && timeout 5400 tar -cf - -C /data --exclude='temp-*.rdb' *.rdb || tar -cf - --files-from=/dev/null"
Or using find to handle the empty-directory case gracefully:
/bin/sh -c "timeout 5400 find /data -maxdepth 1 -name '*.rdb' ! -name 'temp-*.rdb' -print0 | tar -cf - --null -T -"
The previous command (tar ... .) did not have this issue since . always matches the directory itself, even when empty.
Notes
PR #498 changed the redis-persistent backup command to only back up
*.rdbfiles rather than the entire/datadirectory. The command fails when/datacontains no.rdbfiles.The
uselagoon/redis-7-persistentimage setsWORKDIR /data, so the*.rdbglob expands correctly from/datawhen files are present. However, busybox ash does not supportnullglob, so when no.rdbfiles exist (a fresh Redis pod that has not yet writtendump.rdb), the shell passes the literal string*.rdbto tar. Tar then tries to open a file named*.rdbinside/datavia the-Cpath and fails.This means the first k8up backup of a newly-provisioned Redis persistent service will always fail. After Redis writes its first
dump.rdb, subsequent backups succeed.Reproduction
Fix
The simplest approach that stays closest to the original command:
/bin/sh -c "ls /data/*.rdb 2>/dev/null | grep -q . && timeout 5400 tar -cf - -C /data --exclude='temp-*.rdb' *.rdb || tar -cf - --files-from=/dev/null"Or using
findto handle the empty-directory case gracefully:/bin/sh -c "timeout 5400 find /data -maxdepth 1 -name '*.rdb' ! -name 'temp-*.rdb' -print0 | tar -cf - --null -T -"The previous command (
tar ... .) did not have this issue since.always matches the directory itself, even when empty.Notes
core-v2.32.0temp-*.rdbfiles from Updates redis backup to only copy non-temp root rdb files #498 is correct; only the empty-case handling needs fixing