-
Notifications
You must be signed in to change notification settings - Fork 0
/
ntsyncer
executable file
·52 lines (38 loc) · 1.55 KB
/
ntsyncer
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
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl
#rsync caller script for my notes files (the name 'ntsyncer' stands for 'note synchronizer')
#2013-04-09
#invoke from the command line like ntsyncer [from|to] [location]
#from|to: from syncs from the other location to here, to syncs from here outwards.
#location is an identifier for a known location.
#out, in, and location are hard-coded. It's relative to the machine you're running on. So this script can be installed globally and run from anywhere on the machine. I allow it to be specified so that in the future more locations could be added.
#define here
chomp ($sysname = `hostname`);
print "we are at $sysname\n";
if ($sysname eq 'localhost'){
print "executing block concerning localhost\n";
$here = "path/to/local/logs";
$there = "/path/to/remote/logs";
$otherhost = "snel";
} elsif ($sysname eq 'remotehost'){
print "executing block concerning remotehost\n";
$here = "/path/to/remote/logs";
$there = "/path/to/local/logs";
$otherhost = "localhost";
} else {
print "nothing\n";
}
$direction = shift @ARGV;
print "direction is $direction\n";
$location = shift @ARGV;
print "location is $location\n";
if ($direction eq 'from'){
print "executing 'from' block\n";
print "syncing from $location:$there to $here\n";
system "rsync -tviu $location:$there/*.txt $here";
} elsif ($direction eq 'to'){
print "executing 'to' block\n";
print "syncing from $here to $location:$there\n";
system "rsync -tviu $here/*.txt $location:$there"; #why is this not working?
} else {
print "nothing\n";
}