Project

General

Profile

Feature #4061

GIT handler

Added by SRG about 5 years ago. Updated about 5 years ago.

Status:
In Progress
Priority:
Normal
Assignee:
Category:
new handler
Target version:
-
Start date:
09/26/2012
Due date:
% Done:

10%

QA Check:

Description

It's awfully simple but i'm right now using this handler to backup my git repositories

setsection git
getconf destination
getconf repository

debug 1 "Repositories to backup :" 
for r in $repository ; do
  info "Repository to backup [$r]" 
done

if [ ! $test ]; then
  mkdir -p $destination
  cd $destination
  for r in $repository ; do
    b=`echo ${r##*/} | sed 's/.git$//'`
    if [ -d $b ] ; then
      info "Now updating repository [$r] to [$b]" 
      cd $b
      git pull
      exit_status=$?
      cd ..
    else
      info "Now backuping repository [$r] to [$b]" 
      git clone $r
      exit_status=$?
    fi
    if [ $exit_status == 0 ]; then
      info "success!" 
    else
      error "failed to backup [$r]" 
      rm -rf $r
    fi
  done
fi

with configuration

[git]
log = /var/log/backupninja/git-backup-github.log
destination = /mnt/external/backups/backups/git/github/
repository = https://github.com/user/repo1
repository = https://github.com/user/repo2

Feel free to adapt / enhance it (in addition to the svn/cvs ones)

History

#1 Updated by intrigeri about 5 years ago

  • Category set to new handler
  • Status changed from New to In Progress
  • Assignee set to SRG
  • % Done changed from 0 to 10

Hi!

Thanks for your contribution to backupninja.

I think rhatto has an other attempt at a Git handler in the git branch of his repository: git://git.sarava.org/backupninja.git -- perhaps you should merge efforts?

In case you want to get such a handler merged upstream, here's a very quick initial review:

  • lacks helper (for ninjahelper)
  • lacks documented example config file
  • lacks git clone command output capturing (see other handlers: usually, output is logged atc debug level on success, at warning level on error IIRC)
  • lacks shell variables quoting
  • lacks Emacs/Vim modelines
  • please indent in a way that's consistent with the rest of backupninja

Also, some would want to use backupninja to backup locally hosted repositories.
You may not want to implement this right from the beginning, but I think an implementation of a git handler should at least leave room for this other kind of usecases. I don't know how, this probably requires a bit of thought on the "UI" (configuration) side :)

Also available in: Atom PDF