Using Git to Update Existing 1.9 Moodle ... PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Ken Task   
Wednesday, 22 February 2012 10:44
AddThis Social Bookmark Button
first step in migrating to 2.x.

Notes on updating a 1.9 Moodle via git.

Why?  One of the recommendations for migrating is to upgrade the current 1.9 version to the highest available.

First and foremost, backup … repeat … BACKUP your current install.
The web root directory AND also do a sql dump of the database.
DO NOT ATTEMPT GIT UPDATE WITHOUT BACKING UP CURRENT SITE!

Git has to be installed
CentOS 5.7 doesn't/may not have git in the standard repos.
To check for existence in standard repos:
yum list git*
Might show an older version, but that's ok.  Install it.
1.5.5.6-4.el5

Install via 3rd party:
Google search for git el5
One hit (there are others): http://pkgs.repoforge.org/git/

Pay attention to CentOS version and whether the rpm is 32 bit or 64 bit.
Match your box!
Downlod directly to server using wget [URL_to_rpm].

For a CentOS 5.7 x86 64 bit box one will need:
http://pkgs.repoforge.org/git/git-1.7.8.2-2.el5.rf.x86_64.rpm
and the corresponding:
http://pkgs.repoforge.org/git/perl-Git-1.7.8.2-2.el5.rf.x86_64.rpm
files.

After downloading, to install:
rpm -ivh git-1.7.8.2-2.el5.rf.x86_64.rpm perl-Git-1.7.8.2-2.el5.rf.x86_64.rpm

To check if it installed correctly: whereis git
git --version
or
man git

git will use 195.57 MiB more space.
What one gets is really the code for Moodle versions 1.8-2.3.  Matter of fact, until one sets git to checkout a branch, the default is dev-2.3.
git branch -a will show you that.

The following script will not create the [directory_of_19] if it already exist and git will fail.

git clone git://git.moodle.org/moodle.git [directory_of_19;
cd [directory_of_19];
git branch -a;
git branch --track MOODLE_19_STABLE origin/MOODLE_19_STABLE;
git checkout MOODLE_19_STABLE

So one has to use a similar process when updating a Moodle the 'long way'.
cd /var/www/html/
mv moodle19 moodle19.back
then run the script above with 'moodle19' as the directory.

To assure the upgrade process goes without hitches, one has to:
* copy the config.php file from moodle19.back to the newly created moodle19 directory from git

* copy any add-on mod/block from moodle19.back to moodle19.
(suggest making a tar ball of those first then moving the tar ball to the appropriate directory in moodle19 and un-tarring - this keeps ownership and permissions)
Sometimes add-ons of old required one to edit/add things to files in lang/en_utf8/
and may have created folders in lang/en_utf8/help/
Hopefully one documented those.  So if after upgrading via Git the new Moodle 19 shows things like [somelingo] rather than 'English', could be that the lang additions weren't brought over manually.

When upgrading, the process will show what is to be upgraded … mods/blocks/theme, etc..
If it says 'missing from disk', one should stop at that point, go to command line, and move those items into the new moodle19 directory.  After having done those, 're-load' that page so that all items NO LONGER show 'missing from disk'.

Granted, some of these will NOT make the trip to 2 when one migrates.  But, for now, concentrate on getting familiar with git upgrades (process is exactly the same with 2 and, since 2 is pretty much a work in progress, one will appreciate git MORE and MORE when fixes are available for 2).

* assure ownership and permissions are correct: chown apache:apache moodle19 -R

Suggest creating an 'update' script inside the moodle19 directory for EASY (future) updates:
cd /var/www/html/moodle19
nano update
Insert: 'git pull' in the update file (without the 'ticks')
Save the file and exit.
Change permissions to make the update file executable only by root:
chmod u+x update

If you test the script: cd /var/www/html/moodle19 then ./update [ENTER]
you will see a git response saying you are already up to date! ;)

[root@sos sandbox]# ./update
Already up-to-date.

If there were updates to acquire, you'll see ONLY those files that need updating.
(this is much more efficient than CVS and gives one a hint as to what/where to look IF there are issues with the update).

Have successfully switched from CVS updates to git updates by the above steps with sos.tcea.org/sandbox/

'spirit of sharing', Ken
 
 
Total Views: 228