Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created September 21, 2013 02:32
Show Gist options
  • Save mlbright/6646603 to your computer and use it in GitHub Desktop.
Save mlbright/6646603 to your computer and use it in GitHub Desktop.
backup acg-git.autodesk.com
#!/usr/bin/env perl
use strict;
use warnings;
use Cwd qw(abs_path getcwd);
use File::Path qw(make_path);
use File::Spec;
my $backup_dir = "/home/backup";
my $domain = 'acg-git.autodesk.com';
my $base = "ssh://$domain";
my @repos = `ssh $domain "perl bin/repolist.pl"`
; # https://gist.github.com/mlbright/6646553
for my $repo (@repos) {
chomp $repo;
my $path = "$backup_dir$repo";
print "repo: $path\n";
if ( -e $path ) {
my $cwd = getcwd();
chdir $path;
`git remote update`;
chdir $cwd;
}
else {
make_path($path);
my $url = "$base$repo";
`git clone --mirror $url $path`;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment