If you encounter this error while restoring a database using Odoo's web database manager, it might be because the device where your temporary folder is, is out of free space. In my case, it was /tmp. So I couldn't just free up space, so I wanted to change the temporary folder Odoo uses. Turns out Odoo uses the Python module tempfiles and it can use environment variables.
So, to set a different temporary folder, set the TMPDIR environment variable, run Odoo, and then proceed to the database restore.
$ export TMPDIR=/home/jerther