-
Notifications
You must be signed in to change notification settings - Fork 5
/
backup-phone
executable file
·67 lines (54 loc) · 1.5 KB
/
backup-phone
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl
use strict;
use warnings;
sub backup($);
my $dir = "$ENV{HOME}/Code/n9";
my %gitRepos = (
"1sms" => "$dir/backup/backup-sms/repo",
"2call" => "$dir/backup/backup-call/repo",
"3contacts" => "$dir/backup/backup-contacts/repo",
);
sub main(@){
die "Usage: $0\n" if @_ != 0;
print "making sure n9 is ssh-able\n";
system "n9", "-s", "echo found n9!\n";
die "failed" if $? != 0;
my %preHeads = map {$_ => getGitHead($gitRepos{$_})} keys %gitRepos;
backup "dcim-backup";
backup "sync-pixmirror";
backup "sync-pidgin";
backup "sync-mydocs";
backup "sync-home";
backup "sync-dir fbreader backup";
backup "sync-dir klomp backup";
backup "sync-dir swype backup";
backup "sync-dir emumaster backup";
backup "sync-dir logs backup";
backup "sync-qtodo";
backup "sync-mms";
backup "mms-to-sms";
backup "fetch-contacts";
backup "fetch-comm call";
backup "fetch-comm sms";
system "klomp-sync user@`n9` --nopresync";
my %postHeads = map {$_ => getGitHead($gitRepos{$_})} keys %gitRepos;
for my $repo(sort keys %gitRepos){
if($preHeads{$repo} ne $postHeads{$repo}){
print "\nrepo $repo updated:\n";
system "cd $gitRepos{$repo}; git --no-pager show HEAD";
}
}
}
sub getGitHead($){
my $dir = shift;
my $h = `cd $dir; git rev-parse HEAD`;
chomp $h;
return $h;
}
sub backup($){
my $backupScript = shift;
print "\n\n\n=========$backupScript\n";
system "$dir/$backupScript";
die "$backupScript failed" if $? != 0;
}
&main(@ARGV);