-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash5.pl
executable file
·60 lines (49 loc) · 2.12 KB
/
hash5.pl
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
#!/usr/bin/perl
#use strict;
use Date::Parse;
my $Today = localtime();
my $Yesterday = localtime(time-(60*60*24));
my $EpochToday = str2time($Today);
my $EpochYesterday = str2time($Yesterday);
my $Dest = '/nfs';
my $QueryCreated = "'{ \"created_at\" : { \$gte : new Date($EpochYesterday), \$lte : new Date($EpochToday) } }'";
my $QueryUpdated = "'{ \"updated_at\" : { \$gte : new Date($EpochYesterday), \$lte : new Date($EpochToday) } }'";
my $collection;
my $query;
my %Collections = (
'activity_definitions' => $QueryCreated,
'api_keys' => $QueryCreated,
'components' => $QueryCreated,
'contents' => $QueryCreated,
'contextual_streams' => $QueryCreated,
'groups' => $QueryCreated,
'leaderboards' => $QueryCreated,
'networks' => $QueryCreated,
'reward_definitions' => $QueryCreated,
'site_contents' => $QueryCreated,
'sites' => $QueryCreated,
'social_networks' => $QueryCreated,
'style_sets' => $QueryCreated,
'tracks' => $QueryCreated,
'units' => $QueryCreated,
'users' => $QueryCreated,
'activities' => $QueryUpdated,
'rewards' => $QueryUpdated,
'players' => $QueryCreated
);
my $myHashref=\%Collections;
mysubrtn($myHashref);
sub mysubrtn() {
my $myref = shift ;
foreach my $key (sort keys %$myref ) {
unless (my $pid = fork) {
die "Couldn't fork on $key" unless defined $pid;
$SIG{CHLD} = 'IGNORE';
my cmd = '/usr/bin/mongodump -h 127.0.0.1 --port 27017 -db badgeville_production -c $key, '-o', $Dest, '--query', myref->{$key}';
print("$cmd\n");
#exec(@args);
#die "cmd failed:$!"
}
}
}
__END__