Line 239... |
Line 239... |
239 |
sub copyToRemote {
|
239 |
sub copyToRemote {
|
240 |
my ( $path, $dirname, $remoteServer, $remotePath ) = @_;
|
240 |
my ( $path, $dirname, $remoteServer, $remotePath ) = @_;
|
241 |
# first, copy the file
|
241 |
# first, copy the file
|
242 |
#print "rsync -a $path/$dirname $remoteServer:$remotePath > /tmp/lastrsync.log";
|
242 |
#print "rsync -a $path/$dirname $remoteServer:$remotePath > /tmp/lastrsync.log";
|
243 |
#die;
|
243 |
#die;
|
244 |
qx"rsync -a $path/$dirname $remoteServer:$remotePath > /tmp/lastrsync.log";
|
244 |
qx"rsync -a '$path/$dirname' $remoteServer:$remotePath > /tmp/lastrsync.log";
|
245 |
return 'rsync failed with error :' . $? & 127 if $? & 127;
|
245 |
return 'rsync failed with error :' . $? & 127 if $? & 127;
|
246 |
return '';
|
246 |
return '';
|
247 |
}
|
247 |
}
|
248 |
|
248 |
|
249 |
# simply remove everything from the trash directory over $age seconds old
|
249 |
# simply remove everything from the trash directory over $age seconds old
|
Line 349... |
Line 349... |
349 |
&logit( $dirname, $config{'log suffix'}, "Copied to $config{'target server'}:$config{'target staging area'}" );
|
349 |
&logit( $dirname, $config{'log suffix'}, "Copied to $config{'target server'}:$config{'target staging area'}" );
|
350 |
}
|
350 |
}
|
351 |
|
351 |
|
352 |
my $md5sum = &getCheckSum( $dirname );
|
352 |
my $md5sum = &getCheckSum( $dirname );
|
353 |
next unless $md5sum;
|
353 |
next unless $md5sum;
|
354 |
my $rsync = "rsync -av '$config{'local staging area'}/$dirname' $config{'target server'}:$config{'target staging area'}/ > /tmp/lastrsync.log";
|
- |
|
355 |
&logit( $dirname, $config{'log suffix'}, $rsync );
|
- |
|
356 |
if ( system ( $rsync ) == 0 ) { # we succeeded
|
- |
|
357 |
if ( &validateTarget( $config{'target server'}, $config{'target staging area'}, $config{'target final directory'}, $dirname, $md5sum ) ) {
|
354 |
if ( &validateTarget( $config{'target server'}, $config{'target staging area'}, $config{'target final directory'}, $dirname, $md5sum ) ) {
|
358 |
`mkdir -p $config{'local trash dir'}` unless -d $config{'local trash dir'};
|
355 |
`mkdir -p $config{'local trash dir'}` unless -d $config{'local trash dir'};
|
359 |
move( "$config{'local staging area'}/$dirname", "$config{'local trash dir'}/$dirname" );
|
356 |
move( "$config{'local staging area'}/$dirname", "$config{'local trash dir'}/$dirname" );
|
360 |
my $md5File = $dirname . '.' . $config{'md5 suffix'};
|
357 |
my $md5File = $dirname . '.' . $config{'md5 suffix'};
|
361 |
move( "$config{'local staging area'}/$md5File", "$config{'local trash dir'}/$md5File" );
|
358 |
move( "$config{'local staging area'}/$md5File", "$config{'local trash dir'}/$md5File" );
|
362 |
&logit( $dirname, $config{'log suffix'}, "Successfully moved directory $dirname to $config{'target server'}" );
|
359 |
&logit( $dirname, $config{'log suffix'}, "Successfully moved directory $dirname to $config{'target server'}" );
|
363 |
} else {
|
- |
|
364 |
&logit( $dirname, $config{'error suffix'}, "Unable to validate target for $dirname" );
|
- |
|
365 |
}
|
- |
|
366 |
} else {
|
360 |
} else {
|
367 |
&logit( $dirname, $config{'error suffix'}, "Unknown error attempting to rsync $dirname" );
|
361 |
&logit( $dirname, $config{'error suffix'}, "Unable to validate target for $dirname" );
|
368 |
}
|
362 |
}
|
369 |
}
|
363 |
}
|
370 |
|
364 |
|
371 |
|
365 |
|
372 |
1;
|
366 |
1;
|