by Carol Booth.
OK, I've made some progress. Disabling php-fpm seems to have fixed my file links so that localises the problem somewhat. I will post more detail later in case anyone else experiences this.
My problem was compounded by the fact that moodledata wasn't fully restored when I rebuilt moodle, making it harder to spot the actual issue but that can be fixed by reverting to earlier backup.