-
Notifications
You must be signed in to change notification settings - Fork 0
/
meocloud.api.sh
58 lines (37 loc) · 1.06 KB
/
meocloud.api.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
#!/usr/bin/env bash
# Source code for meocloud command line application at:
# https://github.com/jfhenriques/meocloud-upload
API_INIT="meocloud_init"
API_WORK="meocloud_upload"
API_END=""
MEOCLOUD_CONF="/etc/meocloud.conf"
MEOCLOUD_BIN="/usr/bin/meocloud"
meocloud_init() {
[ -f "$MEOCLOUD_CONF" ] && [ -x "$MEOCLOUD_BIN" ] && return 0
log "Failed to init meocloud"
return 1
}
meocloud_upload() {
local $host
local $week
local $fname
local $flocation
local $CLOUD_LOC
local $CLOUD_INDEX
local $ret
host="$(hostname)"
week="$1"
fname="$2"
flocation="$3"
CLOUD_LOC="/backup_${host}/${week}/${fname}"
CLOUD_INDEX="/backup_${host}/backup.index.txt"
log "Sending compressed file to MEOCLOUD"
sync
eval "$USE_NICE $MEOCLOUD_BIN -c \"$MEOCLOUD_CONF\" -f \"$flocation\" -n \"$CLOUD_LOC\" -d" 2>&1 | log
ret=$?
if [ -f "$INDEX_FILE_OUTPUT" ]; then
log "Sending backup index to MEOCLOUD"
eval "$USE_NICE $MEOCLOUD_BIN -c \"$MEOCLOUD_CONF\" -f \"$INDEX_FILE_OUTPUT\" -n \"$CLOUD_INDEX\" -y -d" 2>&1 | log
fi
return $ret
}