Note: You are currently viewing documentation for Moodle 3.8. Up-to-date documentation for the latest stable version of Moodle may be available here: Using Git to backup moodledata.

Using Git to backup moodledata: Difference between revisions

From MoodleDocs
No edit summary
m (actually it does not hurt to backup /muc/config.php)
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Draft}}
{{stub}}


[[GIT]] is a distributed source code management system. For the purpose of this document, GIT's basic feature is that it allows to keep the whole history of a directory tree and track all changes. The basic idea of using GIT as a backup tool is that you can clone you moodledata directory on other disk and/or computer.
[[GIT]] [https://docs.moodle.org/en/Development:Tracking_Moodle_CVS_with_git] is a distributed source code management system. For the purpose of this document, GIT's basic feature is that it allows to keep the whole history of a directory tree and track all changes. The basic idea of using GIT as a backup tool is that you can clone you moodledata directory on other disk and/or computer.
 
Create new file called .gitignore in the moodledata with the following content:
 
cache
lang
localcache
lock
sessions
temp
trashdir


Transform your moodledata into the git repository:
Transform your moodledata into the git repository:
Line 20: Line 30:
  cd /mnt/backup
  cd /mnt/backup
  git clone --no-hardlinks --bare /srv/www/moodledata/.git datamoodle.git
  git clone --no-hardlinks --bare /srv/www/moodledata/.git datamoodle.git


Push changes into a bare clone
Push changes into a bare clone
Line 26: Line 35:
  cd /srv/www/moodledata
  cd /srv/www/moodledata
  git push /mnt/backup/datamoodle.git
  git push /mnt/backup/datamoodle.git
Or, pull changes from the clone (here created on a separate machine)
git --bare fetch ssh://your.moodle.serv.er/backup/datamoodle.git master:master
[[Category:Git]]

Latest revision as of 23:38, 13 January 2015


GIT [1] is a distributed source code management system. For the purpose of this document, GIT's basic feature is that it allows to keep the whole history of a directory tree and track all changes. The basic idea of using GIT as a backup tool is that you can clone you moodledata directory on other disk and/or computer.

Create new file called .gitignore in the moodledata with the following content:

cache
lang
localcache
lock
sessions
temp
trashdir

Transform your moodledata into the git repository:

cd /srv/www/moodledata
git init
git add .
git commit -m "Initial commit of moodledata"

Put following commands into the cronjob

cd /srv/www/moodledata
git add .
git commit -a -m "AUTO: committed changes in moodledata"

Create a backup clone on local machine, e.g. on a separate disk

cd /mnt/backup
git clone --no-hardlinks --bare /srv/www/moodledata/.git datamoodle.git

Push changes into a bare clone

cd /srv/www/moodledata
git push /mnt/backup/datamoodle.git

Or, pull changes from the clone (here created on a separate machine)

git --bare fetch ssh://your.moodle.serv.er/backup/datamoodle.git master:master