Moving moodledata folder has resulted in 2 moodledata folders

Moving moodledata folder has resulted in 2 moodledata folders

by Oliver Boyers -
Number of replies: 14

Hi all, 


I moved my moodledata folder (in maintenance mode) from home/mysystem/public_html to root/www for information privacy reasons. 

I then updated my  config file to point to the new moodledata location. 

I also ensured permissions for this folder were set to 777. 

Everything seems to be working fine but a new moodledata folder has been created at the old location - home/mysystem/public_html

Im concerned that there will be conflicts down the line but it seems as if the system generated this folder. 

My system is on a LAMP stack and im using IOMAD. Moodle 3.5.6

Average of ratings: -
In reply to Oliver Boyers

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Firstly, we can't answer specific questions about Iomad but I know this basic functionality to be no different. 

The only way (I can think of ) that this could happen is if you did not change config.php properly. 

In reply to Howard Miller

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Oliver Boyers -

I dont think its related to IOMAD, I was just mentioning it for context


Could the config.php file still have been cached and the site automatically started creating a new moodle data folders because it got the moodledata path from the cached config file?  

In reply to Oliver Boyers

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Ken Task -
Picture of Particularly helpful Moodlers

According to:

https://www.iomad.org/os-download/

"Iomad is a full Moodle + Iomad download with a few notable changes to core Moodle. Because there are a few small changes to core, please be aware that standard Moodle upgrades and patches will be affected by this. If you are an experienced Moodle developer or Administrator then it is likely you can handle this on your own by reviewing the code, but if you require assistance, be sure to choose the one that best suits you from our ‘stuff you gotta pay for’ menu."

Might check:

https://github.com/iomad/iomad/issues

To see if this is an issue with IOMad.

These forums are for standard/stock moodle code and might not be the best resource for a fork of Moodle that, as a fork, has  'a few notable changes to core Moodle'.

'spirit of sharing', Ken


In reply to Ken Task

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The changes are all around the way course lists are displayed (courses are allocated to companies in Iomad). I'd be very surprised if this is an Iomad issue. 

In reply to Howard Miller

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Ken Task -
Picture of Particularly helpful Moodlers

If that's the case, wonder if OP can do a git diff of some sort to see if there isn't some differences in the area where OP is having issues?

'spirit of sharing', Ken


In reply to Oliver Boyers

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Let's see your config file (minus passwords!!!)

In reply to Howard Miller

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Oliver Boyers -

Thanks guys, here is my config file:


<?php  // Moodle configuration file

unset($CFG);
global $CFG;
$CFG = new stdClass();

$CFG->dbtype    = 'mariadb';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'xxx;
$CFG->dbuser    = 'xxx';
$CFG->dbpass    = 'xxx';
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => '',
  'dbsocket' => '',
  'dbcollation' => 'utf8_unicode_ci',
);

$CFG->wwwroot   = 'MyURL';
$CFG->dataroot  = '/home/lmschartallcamp/moodledata';
$CFG->admin     = 'admin';

$CFG->directorypermissions = 0750;

$CFG->debugusers = '849';

require_once(__DIR__ . '/lib/setup.php');

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!

ini_set ('display_errors', 'on');
ini_set ('log_errors', 'on');
ini_set ('display_startup_errors', 'on');
ini_set ('error_reporting', E_ALL);

The additional folder that was created in the old moodledata location only has 3 folders though. Ive attached an Image to show them. Cache, lock and models.

Attachment Screenshot 2019-05-15 at 13.54.48.png
In reply to Oliver Boyers

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Ken Task -
Picture of Particularly helpful Moodlers

My  2 cents ... deferred to any response from Howard, since he's had some experience with the fork.

So you copied moodledata in /home/lms.../ to /root/moodledata.

And then you also changed

$CFG->dataroot  = '/home/lmschartallcamp/moodledata';
to /root/moodledata in the config.php file and 'something' put it back?

The fact those cached directories do show up in /root/moodledata means moodle code could do that much, but don't think there is anything 'protective' would change the config.php file back!

You probably need to look at other logs of server ... web service errors or system errors for clues.

Got any additional protections you've not mentioned ... like CentOS and seLinux or mod_security for apache?

Also ... don't think I've ever heard of putting a data directory for any application (moodle/WP/Joomla/Mambo/Drupal) in /root for 'privacy'.   /root should be, IMHO, left for the root user of your system.  What is this 'privacy' reason of which you spoke?

The way you are trying to do this is kinda like inviting ;the fox into the hen house', so to speak.

Is there a reason moodledata couldn't be moved to something like /data/?

If you continue down this path, strongly recommend you never let your moodle code (excuse me, fork of moodle code) get behind for security fixes or 'the fox' *might* make an un-desired entrance!!!

'spirit of sharing', Ken

In reply to Ken Task

Re: Moving moodledata folder has resulted in 2 moodledata folders

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There's nothing in Iomad that would cause this. 

The sensible thing is to change the file but make sure it has appropriate permissions. The web server user should NOT be able to update it. 

To be honest, and please don't take this the wrong way, my $00.02 is that you didn't change/save it in the first place. Done this myself. Edited the wrong file etc. 

In reply to Ken Task

Re: Re: Moving moodledata folder has resulted in 2 moodledata folders

by Oliver Boyers -
So my sequence of changes was as follows:

 1. Enable maintenance mode
2. Move moodledata from '/home/lmschartallcamp/public_html/moodledata' to '/home/lmschartallcamp/moodledata'
3. Update config to the version you have above
4. Disable maintenance mode

 We may have a misunderstanding of root. I am using a server managed by a hosting company. The highest directory I have access to is 'lmschartallcamp'. I don't have access to home. ('/home/lmschartallcamp/moodledata') - home being the root I presume?

 Im starting to think that because I moved the moodledata folder before updating the config file, some files and folders were regenerated at the old dataroot before I could update the config file.

 There have been no changes to the files or folders at the old root since the day of the swap.

I moved the moodledata folder our of public_html as guided by this installation guide: https://docs.moodle.org/36/en/Installing_Moodle#Create_the_.28moodledata.29_data_directory which states:

 "IMPORTANT: This directory must NOT be accessible directly via the web. This would be a serious security hole."

 This is the reason I moved the folder.

Protections wise, my server software is managed by my hosts so I'm not 100% on what is being used there. I'll check what security measures are in place by my hosts.

What do you suggest as necessary precautions? I am actually setting up a server at the moment that I will be managing so I will have better control over these things.

 I hope I'm not exposing myself to any additional vulnerabilities. It would be ironic as I'm doing this to further secure the site.

 Again, thank you Ken and Howard for your help. Your knowledge on these forums has helped me numerous times in the last 3 years I have been moodling!
In reply to Oliver Boyers

Re: Re: Re: Moving moodledata folder has resulted in 2 moodledata folders

by Ken Task -
Picture of Particularly helpful Moodlers
Ahhh ... then it's not really true /root user directory of server. That's good! smile in your moodledata directory there should be an .htaccess ... note the 'dot' in front .. to help protect the contents of that directory. It's contents are: deny from all AllowOverride None Note: this file is broken intentionally, we do not want anybody to undo it in subdirectory! So if you copied that might have missed the hidden .htaccess file ... if you moved .htaccess should be there ... check. /home/lmschartallcamp/moodledata location should work ... depending upon how provider has configured user space - that should not be accessible via direct URL ... like https://yoursite/moodledata/ 'spirit of sharing', Ken
Average of ratings: Useful (1)
In reply to Ken Task

Re: Re: Re: Re: Moving moodledata folder has resulted in 2 moodledata folders

by Oliver Boyers -
Yep, the .htaccess file is there. You are correct in saying https://yoursite/moodledata/ isnt accessable. I have checked. So with regard to the duplicate moodledata directory at the old dataroot, do you think my hypothesis above is correct? Im going to back it up and delete it at this point as it seems to be a useless folder.
In reply to Oliver Boyers

Re: Re: Re: Re: Re: Moving moodledata folder has resulted in 2 moodledata folders

by Ken Task -
Picture of Particularly helpful Moodlers

Backing up the duplicate ... non-complete ... missing filedir ... moodledata then removing is a good idea.   Safe.

Double check settings in config.php.

Fixed? smile

'SoS', Ken

In reply to Ken Task

Re: Re: Re: Re: Re: Re: Moving moodledata folder has resulted in 2 moodledata folders

by Oliver Boyers -
Yep fixed. Looked like some dud duplicates that had been regenerated.