Fix backup permission denied by using docker cp instead of direct mount write

The git user inside the gitea container couldn't write to the NAS-mounted
/tmp/backup directory. Now dumps to /tmp first, then uses docker cp to
extract the file to the sidecar's backup directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 08:22:09 +01:00
co-authored by Claude Opus 4.6
parent e17ee68fbd
commit ffdd8bb4b2
+8 -5
View File
@@ -16,18 +16,21 @@ if ! docker inspect gitea >/dev/null 2>&1; then
exit 1 exit 1
fi fi
# Ensure backup directory exists inside gitea container # Run gitea dump to /tmp (writable by git user)
docker exec -u git gitea sh -c "mkdir -p /tmp/backup"
# Run gitea dump
echo "Running gitea dump..." echo "Running gitea dump..."
docker exec -u git -w /tmp gitea \ docker exec -u git -w /tmp gitea \
/app/gitea/gitea dump \ /app/gitea/gitea dump \
-c /data/gitea/conf/app.ini \ -c /data/gitea/conf/app.ini \
--file "/tmp/backup/${BACKUP_FILE}" \ --file "/tmp/${BACKUP_FILE}" \
--skip-log \ --skip-log \
--type zip --type zip
# Copy dump out of gitea container into sidecar's backup dir
docker cp "gitea:/tmp/${BACKUP_FILE}" "${BACKUP_DIR}/${BACKUP_FILE}"
# Clean up temp file inside gitea container
docker exec gitea rm -f "/tmp/${BACKUP_FILE}"
# Verify backup was created # Verify backup was created
if [ ! -f "${BACKUP_DIR}/${BACKUP_FILE}" ]; then if [ ! -f "${BACKUP_DIR}/${BACKUP_FILE}" ]; then
echo "ERROR: Backup file not found at ${BACKUP_DIR}/${BACKUP_FILE}" echo "ERROR: Backup file not found at ${BACKUP_DIR}/${BACKUP_FILE}"