-
Notifications
You must be signed in to change notification settings - Fork 3
/
backup.sh
executable file
·145 lines (129 loc) · 5.41 KB
/
backup.sh
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# Copyright (c) 2016, Silvio Peroni <[email protected]>
#
# Permission to use, copy, modify, and/or distribute this software for any purpose
# with or without fee is hereby granted, provided that the above copyright notice
# and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
BACKUP_DATE="$(date -I)"
# Gently stop all the processes
/home/essepuntato/OC/script/gently-stop.sh
# Wait until both BEE and SPACIN finish
while ps -ef | grep "[p]ython bee.py" > /dev/null || ps -ef | grep "[p]ython spacin.py" > /dev/null; do
# If some of the processes is still active, wait for 60 seconds and check again
sleep 60
done
# Get last statistics
/home/essepuntato/OC/statistics.sh
# Wait for complete statistics
while ps -ef | grep "[p]ython statistics.py" > /dev/null; do
# If some of the processes is still active, wait for 60 seconds and check again
sleep 60
done
sleep 60
# Backup of the OCC
# ar
# backup data
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_ar' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/ar/ -X index.json -ar -P "^[0-9]+/[0-9]+$" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# backup provenance
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_ar_prov' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/ar/ -I "[a-z]*.json" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# be
# backup data
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_be' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/be/ -X index.json -ar -P "^[0-9]+/[0-9]+$" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# backup provenance
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_be_prov' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/be/ -I "[a-z]*.json" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# br
# backup data
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_br' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/br/ -X index.json -ar -P "^[0-9]+/[0-9]+$" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# backup provenance
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_br_prov' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/br/ -I "[a-z]*.json" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# id
# backup data
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_id' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/id/ -X index.json -ar -P "^[0-9]+/[0-9]+$" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# backup provenance
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_id_prov' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/id/ -I "[a-z]*.json" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# ra
# backup data
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_ra' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/ra/ -X index.json -ar -P "^[0-9]+/[0-9]+$" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# backup provenance
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_ra_prov' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/ra/ -I "[a-z]*.json" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# re
# backup data
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_re' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/re/ -X index.json -ar -P "^[0-9]+/[0-9]+$" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# backup provenance
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_re_prov' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/re/ -I "[a-z]*.json" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# prov
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-corpus_prov' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/corpus/prov/ | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# references
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-ref' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/ref/ | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# triplestore
CMD="ssh ocbackup.cs.unibo.it -l oc -t -t 'nc -l -p 5000 | dar_xform -s 500M -w -n - /mnt/backup/oc/$BACKUP_DATE-triplestore' &"
eval $CMD
sleep 10
dar -Q -c - -R /srv/oc/triplestore/ -X "log.txt" -X "nohup.out" | nc -w 1 ocbackup.cs.unibo.it 5000
sleep 30
# Gently run all the processes
/home/essepuntato/OC/script/gently-run.sh