by Ken Task.
@Paul ... let's try another route ...
Setup a file system repo.
https://docs.moodle.org/33/en/File_system_repository
Upload your backup via scp/ftp (in binary mode, not ascii)/ or whatever method you have to access the location of the file system repo you setup with whatever tool you have to upload files.
Then use the file system repo in any course setup to use it and try the restore that way.
Now the subject of this thread is 'localhost' ... we, howver, are talking about your problem on a Debian server still, correct?
'spirit of sharing', Ken