bak ch[anges]
bak revert [host:]/path
+ bak cat [host:]/path
+
bak - push all changed files to server
+See L<http://blog.rot13.org/bak-git> for more information
+
=cut
use warnings;
$command = 'log --patch-with-stat' if $command =~ m/^ch/;
pull_changes( $hostname ) if $command eq 'diff';
if ( $on_host ) {
+ system 'rsync', '-avv', "root\@$hostname:$path", "$hostname/$path";
system 'rsync', '-avv', "root\@$on_host:$path", "$on_host/$path";
open(my $diff, '-|', "diff -Nuw $hostname$path $on_host$path");
while(<$diff>) {
}
} else {
# commands without path will show host-wide status/changes
- my $backup_path = $rel_path ? $backup_path : "$hostname/";
+ my $backup_path = $path ? "$hostname/$path" : "$hostname/";
# hostname must end with / to prevent error from git:
# ambiguous argument 'arh-hw': both revision and filename
# to support branches named as hosts
print $client git "checkout -- $hostname/$path";
system 'rsync', '-avv', "$hostname/$path", "root\@$hostname:$path";
}
+ } elsif ( $command eq 'cat' ) {
+ my $file_path = ( $on_host ? $on_host : $hostname ) . "/$path";
+ open(my $file, '<', $file_path) || warn "ERROR $file_path: $!";
+ while(<$file>) {
+ print $client $_;
+ }
+ close($file);
} else {
print $client "Unknown command: $command\n";
}