-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.pl
41 lines (33 loc) · 995 Bytes
/
sync.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl
use strict;
use warnings;
my $STORAGE_PATH = "/var/www";
my %repos = (
"debian.osuosl.org/debian" => "$STORAGE_PATH/debian",
"ubuntu.osuosl.org/ubuntu" => "$STORAGE_PATH/ubuntu",
);
foreach my $repo (keys %repos) {
my $dir = $repos{$repo};
sync_repo($repo, $dir);
}
sub sync_repo {
my ($repo, $dir) = @_;
my $rsync_cmd = "rsync " .
"--recursive " .
"--links " .
"--perms " .
"--times " .
"--compress " .
"--progress " .
"--delete " .
"rsync://$repo $dir";
print "Syncing $repo to $dir...\n";
system($rsync_cmd);
if ($? == -1) {
print "Failed to execute: $!\n";
} elsif ($? & 127) {
printf "Child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without';
} else {
printf "Child exited with value %d\n", $? >> 8;
}
}