borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
11k stars 741 forks source link

disk is full: `_get_default_tempdir` raises `FileNotFoundError` No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille'] #8199

Closed kmille closed 4 months ago

kmille commented 5 months ago

Hey,

I'm using borg 1.2.8. The remote disk is full and I don't know how to proceed. How can I prune/compact old backups in this situation (even manual with a shell?). Thanks.

kmille@linbox: sudo borgctl -c backup.yml compact                                      
2024-04-30 14:16:34,396 INFO Using config file /etc/borgctl/backup.yml                                        
2024-04-30 14:16:34,398 INFO Executing: BORG_REPO="kmille@ip:borg-laptop" BORG_LOGGING_CONF="/etc/borgctl/logging.conf" BORG_RELOCATED_REPO_ACCESS_IS_OK="yes" BORG_RSH="ssh -p 23 -i /root/.ssh/borg_backup_laptop" /usr/bin/borg 
--verbose compact --progress                 
2024-04-30 14:16:36,239 ERROR Remote: self test test_identical_creation (borg.testsuite.hashindex.HashIndexDataTestCase.test_identical_creation) FAILED:                                           
Remote: Traceback (most recent call last):   
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 339, in test_identical_creation                                      
Remote:     serialized = self._serialize_hashindex(idx1)       
Remote:                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^       
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 314, in _serialize_hashindex                                         
Remote:     with tempfile.TemporaryDirectory() as tempdir:     
Remote:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^    
Remote:   File "/usr/lib/python3.11/tempfile.py", line 993, in __init__                                    
Remote:     self.name = mkdtemp(suffix, prefix, dir)           
Remote:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^           
Remote:   File "/usr/lib/python3.11/tempfile.py", line 496, in mkdtemp                                     
Remote:     prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)                       
Remote:                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                       
Remote:   File "/usr/lib/python3.11/tempfile.py", line 265, in _sanitize_params                            
Remote:     dir = gettempdir()               
Remote:           ^^^^^^^^^^^^               
Remote:   File "/usr/lib/python3.11/tempfile.py", line 438, in gettempdir                                  
Remote:     return _os.fsdecode(_gettempdir())    
Remote:                         ^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 431, in _gettempdir                                 
Remote:     tempdir = _get_default_tempdir() 
Remote:               ^^^^^^^^^^^^^^^^^^^^^^ 
Remote:   File "/usr/lib/python3.11/tempfile.py", line 362, in _get_default_tempdir                        
Remote:     raise FileNotFoundError(_errno.ENOENT,
Remote: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille']                           
Remote:                                      
2024-04-30 14:16:36,240 ERROR Remote: self test test_read_known_good (borg.testsuite.hashindex.HashIndexDataTestCase.test_read_known_good) FAILED:     
Remote: Traceback (most recent call last):   
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 343, in test_read_known_good                                         
Remote:     idx1 = self._deserialize_hashindex(self.HASHINDEX) 
Remote:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 321, in _deserialize_hashindex                                       
Remote:     with tempfile.TemporaryDirectory() as tempdir:     
Remote:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^    
Remote:   File "/usr/lib/python3.11/tempfile.py", line 993, in __init__                                    
Remote:     self.name = mkdtemp(suffix, prefix, dir)           
Remote:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^           
Remote:   File "/usr/lib/python3.11/tempfile.py", line 496, in mkdtemp                                     
Remote:     prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)                       
Remote:                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                       
Remote:   File "/usr/lib/python3.11/tempfile.py", line 265, in _sanitize_params                            
Remote:     dir = gettempdir()               
Remote:           ^^^^^^^^^^^^               
Remote:   File "/usr/lib/python3.11/tempfile.py", line 438, in gettempdir                                  
Remote:     return _os.fsdecode(_gettempdir())    
Remote:                         ^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 431, in _gettempdir                                 
Remote:     tempdir = _get_default_tempdir() 
Remote:               ^^^^^^^^^^^^^^^^^^^^^^ 
Remote:   File "/usr/lib/python3.11/tempfile.py", line 362, in _get_default_tempdir                        
Remote:     raise FileNotFoundError(_errno.ENOENT,
Remote: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille']                           
Remote:              
2024-04-30 14:16:36,241 ERROR Remote: self test test_chunkindex (borg.testsuite.hashindex.HashIndexTestCase.test_chunkindex) FAILED:                   
Remote: Traceback (most recent call last):   
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 94, in test_chunkindex   
Remote:     self._generic_test(ChunkIndex, lambda x: (x, x, x),
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 57, in _generic_test     
Remote:     with unopened_tempfile() as filepath:
Remote:   File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
Remote:     return next(self.gen)
Remote:            ^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/__init__.py", line 65, in unopened_tempfile
Remote:     with tempfile.TemporaryDirectory() as tempdir:
Remote:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 993, in __init__
Remote:     self.name = mkdtemp(suffix, prefix, dir)
Remote:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 496, in mkdtemp
Remote:     prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
Remote:                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 265, in _sanitize_params
Remote:     dir = gettempdir()
Remote:           ^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 438, in gettempdir
Remote:     return _os.fsdecode(_gettempdir())
Remote:                         ^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 431, in _gettempdir
Remote:     tempdir = _get_default_tempdir()
Remote:               ^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 362, in _get_default_tempdir
Remote:     raise FileNotFoundError(_errno.ENOENT,
Remote: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille']
Remote: 
2024-04-30 14:16:36,241 ERROR Remote: self test test_nsindex (borg.testsuite.hashindex.HashIndexTestCase.test_nsindex) FAILED:
Remote: Traceback (most recent call last):
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 90, in test_nsindex
Remote:     self._generic_test(NSIndex, lambda x: (x, x),
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 57, in _generic_test
Remote:     with unopened_tempfile() as filepath:
Remote:   File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
Remote:     return next(self.gen)
Remote:            ^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/__init__.py", line 65, in unopened_tempfile
Remote:     with tempfile.TemporaryDirectory() as tempdir:
Remote:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 993, in __init__
Remote:     self.name = mkdtemp(suffix, prefix, dir)
Remote:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 496, in mkdtemp
Remote:     prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
Remote:                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 265, in _sanitize_params
Remote:     dir = gettempdir()
Remote:           ^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 438, in gettempdir
Remote:     return _os.fsdecode(_gettempdir())
Remote:                         ^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 431, in _gettempdir
Remote:     tempdir = _get_default_tempdir()
Remote:               ^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 362, in _get_default_tempdir
Remote:     raise FileNotFoundError(_errno.ENOENT,
Remote: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille']
Remote: 
2024-04-30 14:16:36,247 ERROR Remote: self test test_resize (borg.testsuite.hashindex.HashIndexTestCase.test_resize) FAILED:
Remote: Traceback (most recent call last):
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 99, in test_resize
Remote:     with unopened_tempfile() as filepath:
Remote:   File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
Remote:     return next(self.gen)
Remote:            ^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/__init__.py", line 65, in unopened_tempfile
Remote:     with tempfile.TemporaryDirectory() as tempdir:
Remote:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 993, in __init__
Remote:     self.name = mkdtemp(suffix, prefix, dir)
Remote:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 496, in mkdtemp
Remote:     prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
Remote:                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 265, in _sanitize_params
Remote:     dir = gettempdir()
Remote:           ^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 438, in gettempdir
Remote:     return _os.fsdecode(_gettempdir())
Remote:                         ^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 431, in _gettempdir
Remote:     tempdir = _get_default_tempdir()
Remote:               ^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 362, in _get_default_tempdir
Remote:     raise FileNotFoundError(_errno.ENOENT,
Remote: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille']
Remote: 
2024-04-30 14:16:36,248 ERROR Remote: self test failed
Remote: Could be a bug either in Borg, the package / distribution you use, your OS or your hardware.
2024-04-30 14:16:36,284 ERROR Connection closed by remote host. Is borg working on the server?
2024-04-30 14:16:36,353 ERROR Borg failed with exit code 2
ThomasWaldmann commented 4 months ago

That rather looks like an issue with your temp directory.

Remote: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille']

But if the fs is completely out of space, that is a bad situation to be in (that's why the docs warn about it).

Can you make the fs bigger? If not, can you copy the files to a bigger fs?

kmille commented 4 months ago

Can you make the fs bigger? If not, can you copy the files to a bigger fs? Nope

ThomasWaldmann commented 4 months ago

OK, then at least check what's up with the temp directory.

Also do a ls -l in the repo/ directory and also in the 2 highest-number subdirs inside repo/data/ and post it below or on a pastebin.

This will get a bit complicated and risky. If it is super important and you don't want to take the risk of making it worse, make a copy of your current repo state.

ThomasWaldmann commented 4 months ago

Also, you might need to execute some borg commands directly as I have no clue about borgctl.

kmille commented 4 months ago

borgctl is just a wrapper, I can just use borg. But you see all the borgs command that are executed. It's one of the remote backup storage. So no worry. But it would be nice to have it up and running again.

borg info fails

kmille@linbox:.ssh sudo borgctl -c 123 info            
2024-05-02 14:42:13,023 INFO Using config file /etc/borgctl/123.yml
Please enter the borg passphrase for kmille@1.2.3.4:borg-laptop: 
2024-05-02 14:42:28,634 INFO Executing: BORG_REPO="kmille@1.2.3.4:borg-laptop" BORG_LOGGING_CONF="/etc/borgctl/logging.conf" BORG_RELOCATED_REPO_ACCESS_IS_OK="yes" BORG_RSH="ssh -i /root/.ssh/borg_123_laptop" /usr/bin/borg --verbose info
2024-05-02 14:42:30,380 ERROR Remote: self test test_identical_creation (borg.testsuite.hashindex.HashIndexDataTestCase.test_identical_creation) FAILED:
Remote: Traceback (most recent call last):
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 339, in test_identical_creation
Remote:     serialized = self._serialize_hashindex(idx1)
Remote:                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3/dist-packages/borg/testsuite/hashindex.py", line 314, in _serialize_hashindex
Remote:     with tempfile.TemporaryDirectory() as tempdir:
Remote:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 993, in __init__
Remote:     self.name = mkdtemp(suffix, prefix, dir)
Remote:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 496, in mkdtemp
Remote:     prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
Remote:                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 265, in _sanitize_params
Remote:     dir = gettempdir()
Remote:           ^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 438, in gettempdir
Remote:     return _os.fsdecode(_gettempdir())
Remote:                         ^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 431, in _gettempdir
Remote:     tempdir = _get_default_tempdir()
Remote:               ^^^^^^^^^^^^^^^^^^^^^^
Remote:   File "/usr/lib/python3.11/tempfile.py", line 362, in _get_default_tempdir
Remote:     raise FileNotFoundError(_errno.ENOENT,
Remote: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/kmille']
Remote: 
2024-05-02 14:42:30,430 ERROR Connection closed by remote host. Is borg working on the server?
2024-05-02 14:42:30,506 ERROR Borg failed with exit code 2

I'm out of space:

kmille@borg01:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            478M     0  478M   0% /dev
tmpfs            98M  468K   98M   1% /run
/dev/sda1       296G  284G     0 100% /
tmpfs           489M     0  489M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            98M     0   98M   0% /run/user/1001

Regarding TMP:

kmille@borg01:~$ ls /tmp/
systemd-private-32fc863ff9e84481940d8eeabf21638f-ntpsec.service-P65kRe  systemd-private-32fc863ff9e84481940d8eeabf21638f-systemd-logind.service-z9cS2x
kmille@borg01:~$ ls /var/tmp/
cloud-init  systemd-private-32fc863ff9e84481940d8eeabf21638f-ntpsec.service-owVh2q  systemd-private-32fc863ff9e84481940d8eeabf21638f-systemd-logind.service-z57NEn
kmille@borg01:~$ ls /usr/tmp
ls: cannot access '/usr/tmp': No such file or directory
kmille@borg01:~$ ls /home/kmille/
borg-more-data  borg-laptop  borg-more-more

kmille@borg01:~$ echo 123 > /tmp/test.txt
-bash: echo: write error: No space left on device

Regarding borg

kmille@borg01:~/borg-laptop$ ls -l 
total 90696
-rw------- 1 kmille kmille      700 Jan  9 12:24 config
drwx------ 3 kmille kmille     4096 Jan  9 12:24 data
-rw------- 1 kmille kmille  5267447 Apr 22 09:39 hints.602
-rw------- 1 kmille kmille 87578378 Apr 22 09:39 index.602
-rw------- 1 kmille kmille      190 Apr 22 09:39 integrity.602
-rw------- 1 kmille kmille       16 Apr 30 10:41 nonce
-rw------- 1 kmille kmille       73 Jan  9 12:24 README
-rw------- 1 kmille kmille     3229 Apr 22 09:39 transactions

kmille@borg01:~/borg-laptop$ ls -l data/
total 12
drwx------ 2 kmille kmille 12288 Apr 30 10:42 0

kmille@borg01:~/borg-laptop$ ls data/0/ -lv
...
-rw------- 1 kmille kmille        17 Apr 22 09:39 599
-rw------- 1 kmille kmille        49 Apr 22 09:39 600
-rw------- 1 kmille kmille      1885 Apr 22 09:39 601
-rw------- 1 kmille kmille        17 Apr 22 09:39 602
-rw------- 1 kmille kmille 524389521 Apr 30 10:25 603
-rw------- 1 kmille kmille 524980570 Apr 30 10:28 604
-rw------- 1 kmille kmille 524485294 Apr 30 10:31 605
-rw------- 1 kmille kmille 524753901 Apr 30 10:34 606
-rw------- 1 kmille kmille 524298357 Apr 30 10:35 607
-rw------- 1 kmille kmille 525603612 Apr 30 10:37 608
-rw------- 1 kmille kmille 524850642 Apr 30 10:39 609
-rw------- 1 kmille kmille 526923171 Apr 30 10:41 610
-rw------- 1 kmille kmille 527638641 Apr 30 10:42 611
-rw------- 1 kmille kmille 484970496 Apr 30 10:44 612
kmille@borg01:~/borg-laptop$ 

Anything else you need? Thanks for your support!

ThomasWaldmann commented 4 months ago
/dev/sda1       296G  284G     0 100% /

No, you are not really out of space, you have ~12GB left.

For ext4 (ext3, ext2), there is a "reserved free space only for root" percentage you can adjust with tune2fs.

So:

kmille commented 4 months ago

Thanks! After running tune2fs -m 1 /dev/sda1I could use borg again (prune/compact). Thanks!