Is there a graceful way to shutdown automated backups while they are running?

Is there a graceful way to shutdown automated backups while they are running?

by Paul Lindgreen -
Number of replies: 4
Picture of Particularly helpful Moodlers

We are looking to implement automated backups but have concerns it will adversely affect overall performance. We have hundreds of courses and the backup process will likely run a long time.

Is there a recommended approach to killing a running automated backup process if we notice its adversely affecting performance? I use Windows server and IIS,

While the automated backups are running a CLI process shows up Task Manager, I could end the process but was concerned it may have adverse unintentional consequences, perhaps the CLI is even the regular cron job and I'm ending the wrong process too.

Is there a more graceful and safer way to shutdown automated backups while they are running?

If I alter the front end settings to exclude the day the backups are currently running on could that gracefully end the automated backups?

Thanks

====

environment moodle 2.7, windows server/IIS

Average of ratings: -
In reply to Paul Lindgreen

Re: Is there a graceful way to shutdown automated backups while they are running?

by Ken Task -
Picture of Particularly helpful Moodlers

Could do this ... install course size report ... run it.  Determine which are the larger courses - which are the smallest courses.

From command line, use the moodlecode/admin/cli/ backup.php script that is in a script and loops through a listing of courses to backup.  List might include 2 large course and small courses.   Two of three of these list.  Run them under an operating system cron.

It's a work around, but ....

'spirit of sharing', Ken

In reply to Paul Lindgreen

Re: Is there a graceful way to shutdown automated backups while they are running?

by Ken Task -
Picture of Particularly helpful Moodlers

After re-reading, realized that response didn't really answer the question ... so ... am sticking my neck out cause I don't run windows, but ... on the linux platform, I've never found a 'graceful' way of ending a process.  kill -9 pid does the job, but if the process was involved in building a backup, the process never reached the part in code that 'cleaned up', thus manual clean up was necessary, unless there is a scheduled clean up.  2.7 now has scheduled task that one could run manually but didn't see in the listing of task the clean up of moodledata/temp/backup/ files and diretories (folders).   There is one to clean up backup tables, however.

If you haven't implemented auto backups yet, then sounds like one is anticipating issues.  The first run autobackups will be perhaps the most intensive.   There is no info in the tables that Moodle could use as to when the courses were backed up last, etc..

There is a way to kinda tippytoe into auto backups, however.   Install course size report.  Run it.   Get the course ID's of the top 5 courses in size .... let's say it shows 5,234,65,31,and 1014.

Use the backup.php script in moodlecode/admin/cli/.   that script takes two parameters ... course ID and the destination for the backups.

In one shell script (I've heard Windows now has "powershell" so you might be able to use that), create the backup command for each course on a separate line:

php /moodlecode/admin/cli/backup.php --courseid=5 --destination=C:\whereever

php /moodlecode/admin/cli/backup.php --courseid=234 --destination=C:\whereever

php /moodlecode/admin/cli/backup.php --courseid=65 --destination=C:\whereever

php /moodlecode/admin/cli/backup.php --courseid=31 --destination=C:\whereever

php /moodlecode/admin/cli/backup.php --courseid=1014 --destination=C:\whereever

Once the script is created, pull out a timer, and start your timer the same time you start the script.

You'll get a better idea of how long the largest courses will take.

Thus, might be able to make a more educated guess as to the scheduling of automated backups in the Moodle UI - would think non-prime time for users in courses - wee hours of AM ... say 2-4 AM.

It's been years since have been in Windows and I assume one can cancel execution of such with keyboard strokes [ctrl][c].   To see what will happen (find out what will be needed to clean up) run the above script and during the first course backup try to cancel it.   Then go check moodledata/backup/temp/ and see what's there.   Also check the systems C:\temp or C:\tmp directories.

That command line script would only  involve PHP executing queries and then executing some action to build backup files, as well as talking to MySQL (eventually) to update tables related to status of last backup, date of last backup, etc..   Killing the script shouldn't affect persons in Moodle using.  Remember, there is a scheduled task that cleans up DB so one might not need to do anything DB wise.

'spirit of sharing', Ken


In reply to Ken Task

Re: Is there a graceful way to shutdown automated backups while they are running?

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

re: Use the backup.php script in moodlecode/admin/cli/.   that script takes two parameters ... course ID and the destination for the backups.

Thanks for the tip, I'll keep it in mind.  I already have a rough idea of the numbers of large backups and total backups, about 20% are 100-500mb the rest of the 500 courses are under 100mb. I don't anticipate the large courses causing the backups to crap out the server (although I am trying to convince people to reduce the size) but the sheer number will likely run a long time (wild guess 4-12hr).

I don't think our server could handle it during the regular business hours without impacting performance, which we've noticed when manually doing a big course now and then throughout the day. We are considering starting a backup at 10pm and praying it ends by 9am, otherwise we'ld need to end this process if regular users are negatively impacted (disable automated backups and kill the process in windows server and hope that stops the backup?)

In reply to Paul Lindgreen

Re: Is there a graceful way to shutdown automated backups while they are running?

by Paul Lindgreen -
Picture of Particularly helpful Moodlers

Follow up:

I've tested killing the process while the backup is running (disable backups in frontend, kill process on server). It seems to be a decent last resort.

I think the remaining courses that were not backed up after the interruption will backup as soon as you enable and set a backup schedule again, even if its for a later date those remaining courses will begin backing up before that time.