Help! all file links broken after restore

Help! all file links broken after restore

by Carol Booth -
Number of replies: 6

I restored my entire moodle 2.6.7 from database and moodledata backup because I upgraded my server from Ubuntu 12.04 to 14.04.  At first, I thought everything was fine, except for a few broken links to images on my front page but now I realise that all file resources and handed in files in assignments seem to be broken.

I thought that my moodledata directory had not been copied properly so attempted replacing with an older backup.  This didn't solve the problem so I attempted a full restore with a new database backup taken at the same time the moodledata backup was taken.  My front page pictures re-appeared but clicking on any file link (resource or submitted in an assignment) produces the error:

Sorry, the requested file could not be found

More information about this error

The only other change is that tIhe URL moodle.myschool.org/moodle used to work for accessing the site as well as moodle.myschool.org but now only the second URL works.  I've moved from apache 2.2 to 2.4 but didn't think I'd changed anything in the virtual server config.

This is a bad situation!  I'm pretty confident my moodledata backed up correctly as I've restored from backups the same way fairly recently.  Any advice welcome.

thanks

Carol

Average of ratings: -
In reply to Carol Booth

Re: Help! all file links broken after restore

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Carol

I restored my entire moodle 2.6.7 from database and moodledata backup because I upgraded my server from Ubuntu 12.04 to 14.04.

So you didn't do a 'dist-upgrade', reinstalled Ubuntu instead, right? If you did a 'dist-upgrade' you could have left Moodle untouched.

> At first, I thought everything was fine, except for a few broken links to images on my front page but now I realise that all file resources and handed in files in assignments seem to be broken.

It is never "a few broken links". It indicates an unresolved problem which you are going to encounter one day, usually at the worst moment.

> I thought that my moodledata directory had not been copied properly so attempted replacing with an older backup. This didn't solve the problem...

I would have expected that. The moodle database and the directory moodledata are tightly coupled.

> so I attempted a full restore with a new database backup taken at the same time the moodledata backup was taken.

That sounds better.

> My front page pictures re-appeared but clicking on any file link (resource or submitted in an assignment) produces the error:
>
> Sorry, the requested file could not be found
>
> More information about this error

What those "More information" were, could be interesting. ;)

What you attempt is well tested and documented under https://docs.moodle.org/en/Moodle_migration.

> The only other change is that tIhe URL moodle.myschool.org/moodle used to work for accessing the site as well as moodle.myschool.org but now only the second URL works.

Unless you know exactly what you are doing, a Moodle site should have _one_ URL, the one in config.php! (There are advanced configurations and hacks to do anything, you can't ask those things here.)

> I've moved from apache 2.2 to 2.4 but didn't think I'd changed anything in the virtual server config.

The Apache upgrade came as a result of the Ubuntu upgrade, I believe. That shouldn't be a problem, if you took over the old (Apache) configuration to the new one. BTW, when you say "virtual server", you mean Apache virtual hosts, right?

> This is a bad situation! I'm pretty confident my moodledata backed up correctly as I've restored from backups the same way fairly recently. Any advice welcome.

A backup which was not restored is not a good backup! wink
In reply to Visvanath Ratnaweera

Re: Help! all file links broken after restore

by Carol Booth -

Hi Visvanath

Thanks for the reply. 

>So you didn't do a 'dist-upgrade', reinstalled Ubuntu instead, right? If you did a 'dist-upgrade' you could have left Moodle untouched.

I didn't do dist-upgrade because my moodle server has been running for many years and extra packages have been installed at times along the way and I wanted a clean install to match exactly what I had tested on my test server.  I had successfully fully restored my live moodle onto 14.04 on the test server a couple of weeks before I did the rebuilt.  Unfortunately, I'm not able to access the test server now as it's only available on my internal network and I'm now out of the office.

>> Sorry, the requested file could not be found
.>
.> More information about this error

>What those "More information" were, could be interesting. ;)

'more information' was simply the link to moodledocs provided by the moodle error message at https://docs.moodle.org/26/en/error/moodle/filenotfound sorry, I thought I had pasted the link not just the text.

>Unless you know exactly what you are doing, a Moodle site should have _one_ URL, the one in config.php! (There are advanced configurations and hacks to do anything, you can't ask those things here.)

I wasn't doing any crazy hacks - just my apache 2.2 setup had an alias in the virtual host for

alias /moodle /usr/share/moodle

which worked.  My apache 2.4 has the same alias but it doesn't appear to work.

I have been able to confirm that my first restore of moodledata did not copy completely and have been to locate missing files in the database and backed up moodledata using NathanFriend's advice: http://www.nathanfriend.co.uk/find-where-moodle-2-has-put-your-file/

> A backup which was not restored is not a good backup! wink

very true.  If I had my time over, I would have completely repeated the process one more time on my test server with the very latest backup and let it run for a while.  However, I gave in to time pressure and now I'm here. 

Having said that, I had checked backup sizes and times before starting the process and having found the files last night, I am confident that the backups were correctly taken and can be restored.  My next move will be to restore onto a server running apache 2.2 but I can't do this until I can get into the office on Monday sad

I think the problem must be with my new configuration of apache 2.4 (also now using php-fpm) or else some permissions problem on moodledata.  I've done

chown -R www-data:www-data moodledata
chmod -R 0770 moodledata

which I believe are the best settings and the ones I was using beforehand. 

I'm just sure I've missed something and was hoping a second person could look on with a cool head and spot it smile 

Carol

One more piece of information:  I have submitted a file to an assignment since the 'upgrade' tongueout and the link to it appears as expected but the file itself is inaccessible. Again, the file exists in moodledata (I found it using the method I mentioned above) and can be downloaded direct from the server.

In reply to Carol Booth

Re: Help! all file links broken after restore

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.

In reply to Carol Booth

Re: Help! all file links broken after restore

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Carol

Your problem is a delicate one. I don't think it makes much sense to do control experiments in various machines in different LANs. Since you seem to have a reliable backup, to have to tweak the production server.

Two thinks which come to my mind: a) try changing Moodle's slasharguments setting b) admin/tool/replace script or its equivalent was run?

Is there any pattern in the broken links? Compare the URLs in the browser footer for working and not working files.
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Help! all file links broken after restore

by Carol Booth -

Hi Visanth

I'm happy to say that my moodle is properly working now.  I had 2 problems:

1. incorrect setup of php-fpm
The change to apache 2.4 was not the problem in itself but I had set up php-fpm incorrectly and it was failing to allow file downloads.  I've simply reverted to using the old setup of php5 with mpm_prefork instead of php-fpm with mod_proxy and mpm_event for now.  This means I've lost a hoped-for speed gain but am no worse off than before my upgrade.

2. incomplete restore of my moodledata backup
I'd copied my backed up moodledata across the network a couple of times and one of those operations wasn't complete properly.  I could have saved myself a lot of time with du -sh moodledata (which shows total disk usage of the directory moodledata).  My original backup was 88 GB but the restored moodledata directory was only about 30GB.

Your suggestion about slasharguments looks helpful to me - checking the apache documentation http://httpd.apache.org/docs/current/mod/core.html I wonder if my setup with php-fpm may have defaulted to AcceptPathInfo off. I'll do some more checking on that.

Thanks for your time.  It's really helpful to have someone to talk to when things go wrong!

Carol

In reply to Carol Booth

Re: Help! all file links broken after restore

by Jörg S. -

Hi,

what about the sourcecode of your page? Are there some blank lines in the beginning? Maybe even when you download an image?

Make sure that you have no ?> at the end of your config.php and no Blank Lines etc.

Schorsch