In my case, I am using gogs on an Azure VM, which has a not-large main drive, but a rather large drive that only exists as long as the VM is running.
Given that the gogs backup is rather disk hungry, I found the need to move its use away from /tmp and onto the temporary disk.
# Since "resource" is owned by root, make a subfolder and make it world-usable
sudo mkdir /mnt/resource/TEMP && sudo chmod 777 /mnt/resource/TEMP
# Verify
ls -ld /mnt/resource/TEMP
# while TMP and TEMP did not affect gogs, TMPDIR DID, indicating that gogs uses mktemp
TMPDIR=/mnt/resource/TEMP ./gogs backup