Skip to content

Instantly share code, notes, and snippets.

@michael-milette
Created April 16, 2019 16:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michael-milette/79079eecfcbc250c5874b24b940e20e9 to your computer and use it in GitHub Desktop.
Save michael-milette/79079eecfcbc250c5874b24b940e20e9 to your computer and use it in GitHub Desktop.
Update Moodle version
# Script: update-moodle.sh
# From: https://gist.github.com/
# This script will update Moodle within the same major version (example: 3.6.1 to 3.6.3).
# The nice thing about this simple approach is that it won't affect your plugins.
# Assumes you used "git clone" to create and install your instance of Moodle. If you did not, don't use this script!
#
# Copyright TNG Consulting Inc.
# Author: Michael Milette - <www.tngconsulting.ca>
# Release: 1.0 Alpha - 2019-04-16
#
# License:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# IMPORTANT: Always ensure you have a good backup of your moodle site, moodledata and database before using this script.
# dirroot corresponding to the wwwroot of your Moodle website.
MOODLE=/var/www/html
# PHP executable.
PHP=/usr/bin/php
# Change to Moodle directory.
cd $MOODLE
# Enable Moodle Maintenance Mode.
$PHP admin/cli/maintenance.php --enable
# Update Moodle within the same version from origin.
git pull
# Execute Moodle upgrade in non-interactive mode.
$PHP admin/cli/upgrade.php --non-interactive
# Purge Moodle cache.
$PHP admin/cli/purge_caches.php
# Disable Moodle maintenance mode.
$PHP admin/cli/maintenance.php --disable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment