-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·51 lines (48 loc) · 1 KB
/
docker-entrypoint.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
#!/bin/bash
set -e
case "$1" in
p4d)
shift
exec /usr/sbin/p4d -C1 $*
;;
checkpoint)
echo "Performing backup of database files only..."
exec /usr/sbin/p4d -C1 -z -jc /backup/
;;
backup)
echo "Doing full backup of database files and library files..."
/usr/sbin/p4d -C1 -z -jc /backup/metadata
if [ -f /backup/library.tgz ]; then
mv /backup/library.tgz /backup/library.prev.tgz
fi
tar czf /backup/library.tgz /library
if [ -f $P4ROOT/server.id ]; then
cp $P4ROOT/server.id /backup
fi
exit 0
;;
restore)
shift
if [ -z $1 ]; then
echo "Usage: restore <checkpoint filename> [journal file]"
exit 1
fi
/usr/sbin/p4d -C1 -z -jv /backup/$1
if [ ! -z $2 ]; then
/usr/sbin/p4d -C1 -jv /backup/$2
fi
tar xzf /backup/library.tgz
if [ -f /backup/server.id ]; then
cp /backup/server.id $P4ROOT
fi
/usr/sbin/p4d -C1 -z -jr /backup/$1
if [ ! -z $2 ]; then
/usr/sbin/p4d -C1 -jr /backup/$2
fi
exit 0
;;
ping)
exec /bin/ping -c 4 8.8.8.8
;;
esac
exec "$@"