make source and destination directory for diff
[bak-git.git] / bak-git-server.pl
index 67262c9..5e656a0 100755 (executable)
@@ -55,6 +55,7 @@ $server_ip ||= '127.0.0.1';
 
 my $shell_client = <<__SHELL_CLIENT__;
 #!/bin/sh
+#echo \$USER/\$SUDO_USER $install `pwd` \$* | nc 127.0.0.1 9001
 echo \$USER/\$SUDO_USER `hostname` `pwd` \$* | nc $server_ip 9001
 __SHELL_CLIENT__
 
@@ -104,7 +105,7 @@ sub pull_changes {
                print $files "$_\n" foreach @_;
                close($files);
        }
-       rsync( qw( -avv --files-from /tmp/$hostname.list root\@$hostname:/ $hostname/ ) );
+       rsync split / /, "-avv --files-from /tmp/$hostname.list root\@$hostname:/ $hostname/";
 }
 
 while (my $client = $server->accept()) {
@@ -167,6 +168,7 @@ while (my $client = $server->accept()) {
                $command = 'log --patch-with-stat' if $command =~ m/^ch/;
                pull_changes( $hostname ) if $command eq 'diff';
                if ( $on_host ) {
+                       mkpath $_ foreach grep { ! -e $_ } ( "$hostname/$dir", "$on_host/$dir" );
                        rsync( '-avv', "root\@$hostname:$path", "$hostname/$path" );
                        rsync( '-avv', "root\@$on_host:$path", "$on_host/$path" );
                        open(my $diff, '-|', "diff -Nuw $hostname$path $on_host$path");
@@ -195,6 +197,8 @@ while (my $client = $server->accept()) {
                        print $client $_;
                }
                close($file);
+       } elsif ( $command eq 'ls' ) {
+               print $client `ls $backup_path`;
        } else {
                print $client "Unknown command: $command\n";
        }