-
Notifications
You must be signed in to change notification settings - Fork 27
/
restore-from-backup
executable file
·49 lines (40 loc) · 1.49 KB
/
restore-from-backup
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
#!/bin/sh
#
# Writes a backup of all Overview's dynamic data to "$1".
#
# Restore it by running "./restore $1".
DIRNAME="$(dirname "$0")"
fail() {
echo "$1" >&2
exit 1
}
[ ! -z "$1" ] || fail "Usage: $0 backup-filename.tar.gz"
[ -f "$1" ] || fail "'$1' is not a file"
[ -r "$1" ] || fail "You do not have access to read '$1'"
echo "This will DESTROY all Overview's live data!"
echo
read -p "Are you sure? [yn] " REPLY
[ "$REPLY" = "y" ] || fail 'You did not enter "y". Aborting.'
. "$DIRNAME"/common.sh
echo "Ensuring Overview is not running..."
"$DIRNAME"/stop
echo "Wiping data..."
docker volume remove overviewlocal_overview-database-data
docker volume remove overviewlocal_overview-searchindex-data
docker volume remove overviewlocal_overview-blob-storage
docker volume create overviewlocal_overview-database-data
docker volume create overviewlocal_overview-searchindex-data
docker volume create overviewlocal_overview-blob-storage
echo "Inserting backup data..."
# We use ubuntu, not busybox, because its tar/gzip are far faster
#
# Plus, the "-p" flag is handy
docker run \
--volume overviewlocal_overview-database-data:/var/lib/postgresql/data \
--volume overviewlocal_overview-searchindex-data:/var/lib/overview/searchindex \
--volume overviewlocal_overview-blob-storage:/var/lib/overview/blob-storage \
--volume "$(realpath "$1")":/in.tar.gz \
--rm "$UBUNTU_IMAGE" \
tar -xzpf /in.tar.gz -C /
echo "Restore complete!"
echo "Run \"$DIRNAME/start\" to start Overview with the restored data."