Using Git to backup lmsdata

Using Git to backup lmsdata

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 lmsdata directory on other disk and/or computer.

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

cache
lang
localcache
lock
sessions
temp
trashdir

Transform your lmsdata into the git repository:

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

Put following commands into the cronjob

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

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

cd /mnt/backup
git clone --no-hardlinks --bare /srv/www/lmsdata/.git datalms.git

Push changes into a bare clone

cd /srv/www/lmsdata
git push /mnt/backup/datalms.git

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

git --bare fetch ssh://your.lms.serv.er/backup/datalms.git master:master