Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6815

Re: New courses not added to table mdl_backup_courses

$
0
0
by Alain Raap.  

Ken, just thinking out loud, would it be possible to run a bash script against the automated backup php script?
I built a bash script that reads a file with course-ids, calls the backup cli script for each course-id  and that is
run via the Linux cron in the weekend. Only  that script doesn't look at the number of days of a course last
change in the parameters or the number of backups that must be present of each course. I'd like to find a
way to exclude the 'problem'  courses and to run the automated backup without the courses that make the run
fail each time.

This is the (simple) bash-script (file courses.txt contains the course-ids) to run a backup list outside Moodle cron;

#!/bin/bash
# ------------------------------------------------------------------------------
# Script: backup_moodle_courses.sh
#
# - Backup a list of courses with admin/cli/backup.php
#
# Writer:       Alain Raap
# Date:         24-01-2019
# ------------------------------------------------------------------------------
exec > >(tee -i /tmp/backup_moodle_courses.log)
exec 2>&1

# ------------------------------------------------------------------------------
# Set parameters
# ------------------------------------------------------------------------------
SCRIPT="backup_moodle_courses"
COURSES="/tmp/courses.txt"
COMMAND="$MOODLE_ROOT/admin/cli/backup.php"
PHP="$PHP_COMMAND_PATH"
BACKUP_PATH="/path-to-your-automated-backup-courses-map"

echo "${SCRIPT}: Start backup script"
# ------------------------------------------------------------------------------
# Read input file with course-id's to backup
# ------------------------------------------------------------------------------
while read COURSE_LINE ; do
   ID="$(echo ${COURSE_LINE} | cut -d',' -f1)";
   NAME="$(echo ${COURSE_LINE} | cut -d',' -f2)";
   echo "${SCRIPT}: Backup of course: " $ID " - " $NAME;
   echo "$PHP $COMMAND --courseid=${ID} --destination=${BACKUP_PATH}"
   $PHP $COMMAND --courseid=${ID} --destination=${BACKUP_PATH}
done < ${COURSES}

echo "${SCRIPT}: End backup script"
exit 0

Example courses.txt:

1500,Course A
1501,Course B
1502,Course C
1503,Course D


Viewing all articles
Browse latest Browse all 6815

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>