Christophe CasalegnoAutoimmune warrior, Entrepreneur & Bio/Hacker

brain@127.0.0.1:~$ cat post.html

Restore problems and recursion depth with rdiff-backup and Python

rdiff-backup restore problem

This had never happened to me before. Today, a client using an old version of rdiff-backup asked me to restore a file from July, and I ran into this problem:

Fatal Error: Could not find rdiff-backup repository at servers/xxxx/home/userclient/data/www/tmp/unfichier.php

This is a problem I had already encountered once or twice before. It generally requires running a check and sometimes repairing or deleting a corrupted file.

rdiff-backup restore problem

So I launch the command:

rdiff-backup --check-destination-dir /datastore/servers/xxxx/home

After it has been running for several minutes, I get the following error message:

Exception 'maximum recursion depth exceeded' raised of class '<type 'exceptions.RuntimeError'>':

This error is followed by hundreds of lines like this:

File "/usr/lib/python2.7/dist-packages/rdiff_backup/Main.py", line 304, in error_check_Main
    try: Main(arglist)
  File "/usr/lib/python2.7/dist-packages/rdiff_backup/Main.py", line 324, in Main
    take_action(rps)
  File "/usr/lib/python2.7/dist-packages/rdiff_backup/Main.py", line 282, in take_action
    elif action == "check-destination-dir": CheckDest(rps[0])
  File "/usr/lib/python2.7/dist-packages/rdiff_backup/Main.py", line 872, in CheckDest
    dest_rp.conn.regress.Regress(dest_rp)
  File "/usr/lib/python2.7/dist-packages/rdiff_backup/regress.py", line 71, in Regress

When this error appears while running a Python script, it usually means the program (rdiff-backup here) has exceeded the maximum recursion depth. This sometimes happens on file systems where symbolic links have been used incorrectly.

Yet in this particular case, there is no reason to be facing an "infinite recursion".

So let us focus on a solution directly at the rdiff-backup level:

For a homegrown script, the idea would be to set a new recursion limit (10000 in the example below) with:

import sys
sys.setrecursionlimit(10000)

Adding this at the start of the script would be enough. That said, this is not a "homegrown" script, so I prefer an approach that preserves the integrity of the rdiff-backup command. A simple way to do this without changing its code is to launch it directly with Python, adding the setting we need:

python -c "import sys; sys.setrecursionlimit(10000); import rdiff_backup.Main; rdiff_backup.Main.error_check_Main(['--check-destination-dir', '/datastore/servers/xxx/home'])"

The operation ran to completion. Once it had finished, the requested backup restores completed successfully.

Christophe Casalegno / Brain 0verride

You can follow me on: Telegram | YouTube | Twitter | Facebook | LinkedIn | Twitch

Leave a comment

Add a comment
Christophe Casalegno Brain 0verride

Keep it simple
and direct!