-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathexample_plugin.bash
More file actions
executable file
·115 lines (100 loc) · 3.95 KB
/
example_plugin.bash
File metadata and controls
executable file
·115 lines (100 loc) · 3.95 KB
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
#!/bin/bash
set -e
setup_plugin_for_backup(){
echo "setup_plugin_for_backup $1 $2 $3 $4" >> /tmp/plugin_out.txt
if [[ "$3" = "coordinator" || "$3" = "master" ]]
then echo "setup_plugin_for_backup was called for scope = $3" >> /tmp/plugin_out.txt
elif [ "$3" = "segment_host" ]
then echo "setup_plugin_for_backup was called for scope = segment_host" >> /tmp/plugin_out.txt
elif [ "$3" = "segment" ]
then echo "setup_plugin_for_backup was called for scope = segment" >> /tmp/plugin_out.txt
fi
timestamp_dir=`basename "$2"`
timestamp_day_dir=${timestamp_dir%??????}
mkdir -p /tmp/plugin_dest/$timestamp_day_dir/$timestamp_dir
}
setup_plugin_for_restore(){
echo "setup_plugin_for_restore $1 $2 $3 $4" >> /tmp/plugin_out.txt
if [[ "$3" = "coordinator" || "$3" = "master" ]]
then echo "setup_plugin_for_restore was called for scope = $3" >> /tmp/plugin_out.txt
elif [ "$3" = "segment_host" ]
then echo "setup_plugin_for_restore was called for scope = segment_host" >> /tmp/plugin_out.txt
elif [ "$3" = "segment" ]
then echo "setup_plugin_for_restore was called for scope = segment" >> /tmp/plugin_out.txt
fi
}
cleanup_plugin_for_backup(){
echo "cleanup_plugin_for_backup $1 $2 $3 $4" >> /tmp/plugin_out.txt
if [[ "$3" = "coordinator" || "$3" = "master" ]]
then echo "cleanup_plugin_for_backup was called for scope = $3" >> /tmp/plugin_out.txt
elif [ "$3" = "segment_host" ]
then echo "cleanup_plugin_for_backup was called for scope = segment_host" >> /tmp/plugin_out.txt
elif [ "$3" = "segment" ]
then echo "cleanup_plugin_for_backup was called for scope = segment" >> /tmp/plugin_out.txt
fi
}
cleanup_plugin_for_restore(){
echo "cleanup_plugin_for_restore $1 $2 $3 $4" >> /tmp/plugin_out.txt
if [[ "$3" = "coordinator" || "$3" = "master" ]]
then echo "cleanup_plugin_for_restore was called for scope = $3" >> /tmp/plugin_out.txt
elif [ "$3" = "segment_host" ]
then echo "cleanup_plugin_for_restore was called for scope = segment_host" >> /tmp/plugin_out.txt
elif [ "$3" = "segment" ]
then echo "cleanup_plugin_for_restore was called for scope = segment" >> /tmp/plugin_out.txt
fi
}
restore_file() {
echo "restore_file $1 $2" >> /tmp/plugin_out.txt
filename=`basename "$2"`
timestamp_dir=`basename $(dirname "$2")`
timestamp_day_dir=${timestamp_dir%??????}
cat /tmp/plugin_dest/$timestamp_day_dir/$timestamp_dir/$filename > $2
}
backup_file() {
echo "backup_file $1 $2" >> /tmp/plugin_out.txt
filename=`basename "$2"`
timestamp_dir=`basename $(dirname "$2")`
timestamp_day_dir=${timestamp_dir%??????}
cat $2 > /tmp/plugin_dest/$timestamp_day_dir/$timestamp_dir/$filename
}
backup_data() {
echo "backup_data $1 $2" >> /tmp/plugin_out.txt
filename=`basename "$2"`
timestamp_dir=`basename $(dirname "$2")`
timestamp_day_dir=${timestamp_dir%??????}
cat - > /tmp/plugin_dest/$timestamp_day_dir/$timestamp_dir/$filename
}
restore_data() {
echo "restore_data $1 $2" >> /tmp/plugin_out.txt
filename=`basename "$2"`
timestamp_dir=`basename $(dirname "$2")`
timestamp_day_dir=${timestamp_dir%??????}
cat /tmp/plugin_dest/$timestamp_day_dir/$timestamp_dir/$filename
}
delete_backup() {
echo "delete_backup $1 $2" >> /tmp/plugin_out.txt
timestamp_day_dir=${2%??????}
rm -rf /tmp/plugin_dest/$timestamp_day_dir/$2
if [ -z "$(ls -A /tmp/plugin_dest/$timestamp_day_dir/)" ] ; then
rm -rf /tmp/plugin_dest/$timestamp_day_dir
fi
}
# utility/debugging function to maintain parity with ddboost and s3 plugin
list_directory() {
echo "list_directory $1 /tmp/plugin_dest" >> /tmp/plugin_out.txt
ls /tmp/plugin_dest
}
# utility/debugging function to maintain parity with ddboost and s3 plugin
delete_directory() {
echo "delete_directory $1 /tmp/plugin_dest" >> /tmp/plugin_out.txt
rm -rf /tmp/plugin_dest
}
plugin_api_version(){
echo "0.5.0"
echo "0.5.0" >> /tmp/plugin_out.txt
}
--version(){
echo "example_plugin version 1.1.0"
echo "example_plugin version 1.1.0" >> /tmp/plugin_out.txt
}
"$@"