By default, duplicity will use the system default temporary directory, which on Unix is usually /tmp. If you have insufficient disk space in /tmp for the files you're trying to restore from S3, the restore operation will eventually fail with "IOError: [Errno 28] No space left on device".
One thing you can do is create another directory on a partition with lots of disk space, and specify that directory in the duplicity command line using the --tempdir command line option. Something like: /usr/local/bin/duplicity --tempdir=/lotsofspace/temp
However, it turns out that this is not sufficient. There's still a call to os.tmpfile() buried in the patchdir.py module installed by duplicity. Consequently, duplicity will still try to create temporary files in /tmp, and the restore operation will still fail. As a workaround, I solved the issue in a brute-force kind of way by editing /usr/local/lib/python2.5/site-packages/duplicity/patchdir.py (the path is obviously dependent on your Python installation directory) and replacing the line:
tempfp = os.tmpfile()
with the line:
tempfp, filename = tempdir.default().mkstemp_file()
(I also needed to import tempdir at the top of patchdir.py; tempdir is a module which is part of duplicity and which deals with temporary file and directory management -- I guess the author of duplicity just forgot to replace the call to os.tmpfile() with the proper calls to the tempdir methods such as mkstemp_file).
This solved the issue. I'll try to open a bug somehow with the duplicity author.
3 comments:
Hi Grig,
Did you try setting TMPDIR or TMP in the environment? I believe os.tmpfile() supports that, just like the tempfile module does.
Hi, Sidney -- good idea, I'll try that.
Thanks!
Grig
Hi there
I have tried that with setting TMPDIR but i cant get it to work.
Could you please post the code you used ?
/Søren
Post a Comment