5 Simpliest possible backup from remote host (with natcat as
6 only depenency) to ad-hoc remote server
8 Install on client with:
10 echo install | nc 10.60.0.92 9001 > bak ; chmod 755 bak
20 my $dir = shift @ARGV || die "usage: $0 /backup/directory\n";
23 system 'git init' unless -e '.git';
25 my $server = IO::Socket::INET->new(
32 while (my $client = $server->accept()) {
33 my ($command,$path,$message) = split(/\s+/,<$client>,3);
34 my $ip = $client->peerhost;
38 if ( $command eq 'install' ) {
39 print $client '#!/bin/sh',$/,'echo $* | nc 10.60.0.92 9001',$/;
43 warn "$ip [$command] $path | $message\n";
46 system 'ssh-copy-id', "root\@$ip";
53 mkpath "$ip/$dir" unless -e "$ip/$dir";
55 if ( $command eq 'add' ) {
56 warn 'rsync', "root\@$ip:$path", "$ip/$path";
57 system 'rsync', "root\@$ip:$path", "$ip/$path";
58 system 'git', 'add', "$ip/$path";
60 system 'rsync', "root\@$ip:$path", "$ip/$path";
61 $message ||= "$command $ip $path";
62 system 'git', 'commit', '-m', $message, "$ip/$path";