This file is made obsolete by github-backup.py.

This commit is contained in:
Anthony Gargiulo 2012-06-23 13:24:48 -04:00
parent 7a874e281d
commit 0330e39d96

View file

@ -1,33 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
die "Please supply a github username and backups directory\n" unless (@ARGV == 2);
my $username = $ARGV[0];
my $backupdir = $ARGV[1];
my $page = get("http://github.com/api/v2/yaml/repos/show/$username");
die "Could not complete github API query for $username\n" unless defined $page;
my @list = split(/\n/, $page);
my @urls = grep { /url/ } @list;
my @giturls = grep s/ :url: https/git/, @urls;
@urls = @giturls;
my @reponames = grep s/.*$username\///, @giturls;
for(my $i = 0; $i < @urls; ++$i){
my $url = $urls[$i];
my $name = $reponames[$i];
unless(-e $backupdir){
system("mkdir $backupdir") and die "Couldn't make $backupdir.\n";
}
unless(-e "$backupdir/$name"){ #We haven't backed this up before, let's clone it
print "CLONING REPOSITORY: $url\n";
system("cd $backupdir && git clone $url") and die "Encountered an error while git-cloning repository $name\n";
}
else{ #We've backed it up before, just fetch the most recent copy
print "REPOSITORY EXISTED, FETCHING: $name\n";
system("cd $backupdir/$name && git fetch -q") and die "Encountered an error while git-fetching repository $name\n";
}
}