Backup files - MySQL, course, moodle folder and Moodledata

Backup files - MySQL, course, moodle folder and Moodledata

by Frankie Kam -
Number of replies: 3
Picture of Plugin developers

Hiya All

I am using Moodle 2.7.2. Running on a Linux dedicated server.

In the advent of a major Moodle server disaster,  let's say I lost everything on the server, but I had earlier made backups of :

(1) MySQL database export files (*.sql.gz file)
(2) Course backup files (*.MBZ files)
(3) Moodledata folder

AND assuming that I have re-installed Moodle, then can I just restore (1) and (2) and have my whole site up and running as it was before the melt-down? Meaning that I don't need to copy by Moodledata folder since (1) and (2) have been imported and restored.

The reason I am asking is because my Moodledata folder is now 2++ Gigabytes (I can't understand why!?) but my Course backup files in total are not very large (less than 300Mb).

So I would like to ask my question again, assuming I have restored by MySQL database AND all my Course MBZ files, will that be enough to get my Moodle site up and running again?

Anyone?

Regards
Frankie Kam 

Average of ratings: -
In reply to Frankie Kam

Re: Backup files - MySQL, course, moodle folder and Moodledata

by Frankie Kam -
Picture of Plugin developers

Okay, I've just discovered that my trashdir folder takes up 1++ Gigabytes of data. Which is more than 50% of the total space of my moodledata folder. What can I do to reduce the trashdir folder's size? Delete all its contents?

I am hesitate to do this blindly as my courses are quite critical and I cannot afford a case of physical files gone (manually deleted), but there are links or references in the MySQL database which still pointing to the physical files. I don't want to break my Moodle for the sake of mass removals of temp or trash files.

I need some advice here.

Regards
Frankie Kam 

In reply to Frankie Kam

Re: Backup files - MySQL, course, moodle folder and Moodledata

by Ken Task -
Picture of Particularly helpful Moodlers

Got command line access?

In a 2.7.x there are now command line scheduled task which are actually parts
of the overall cron job.

cd moodlecode/admin/tool/task/cli/

Then run:
php schedule_task.php --list
to see a list of those could call individually.  Of the server I am looking
at right now (a 2.7.highest), the following look like they might clean up
files for you.

\core\task\file_temp_cleanup_task                  55 */6 * * * *    ASAP
\core\task\file_trash_cleanup_task                 55 */6 * * * *    ASAP

To run the trash_cleanup_task:

scheduled_task.php --execute=\\core\\task\\file_trash_cleanup_task

Yes the double \\ are needed.

Will show something like this:

Scheduled task: Cleanup files in trash
Deleting old draft files... ... started 02:43:19. Current memory use 3.8MB.
done.
Deleting orphaned preview files... ... started 02:43:19. Current memory use 4.2MB.
done.
Cleaning up files from deleted contexts... ... started 02:43:19. Current memory use 4.2MB.
done.
Deleting trash files... ... started 02:43:19. Current memory use 4.2MB.
done.
... used 5 dbqueries
... used 0.19257116317749 seconds
Task completed.

Also, am having to do this right now for a site that's in dire need of space ... it's ok to remove manually what is in trashdir if needed.   Nothing in there should be linked to courses any longer.

As to what might have caused the increase ....

automated backups running?   Run away autobackups can happen ... dealing with a server right now that had that happen.  Drive filled up.  Caused DB corruption eventually.

automated backups that failed?

cd /pathtomoodledata/temp/backup/

If you see long directory names like with past dates

20f571713fc8971cbacdddc230fa3fdf

more than likely they are failed backups.

cd 20f571713fc8971cbacdddc230fa3fdf and inspect.

ls -l

IF you see no .mbz file and no moodle_backup.xml it's a backup attempt that failed.

Safe to remove manually.

''spirit of sharing', Ken


In reply to Ken Task

Re: Backup files - MySQL, course, moodle folder and Moodledata

by Frankie Kam -
Picture of Plugin developers

Hi Ken

Thanks for your reply. I managed to clear 75Mb from my trashdir folder so far. I appreciate your long reply - too bad I don't have root and command line access. But many thanks nevertheless. Will come in useful.

Regards
Frankie Kam