-
Notifications
You must be signed in to change notification settings - Fork 27
/
backup
executable file
·32 lines (26 loc) · 1017 Bytes
/
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
#!/bin/sh
#
# Writes a backup of all Overview's dynamic data to "$1".
#
# Restore it by running "./restore-from-backup $1".
BACKUP_BASENAME="$(basename "$1")"
BACKUP_DIRNAME="$(realpath "$(dirname "$1")")"
fail() {
echo "$1" >&2
exit 1
}
[ -z "$1" ] && fail "Usage: $0 backup-filename.tar.gz"
# Write to the file before starting Docker: we need the file to exist for
# Docker to mount it.
: > "$1" || fail "Could not create file '$1'. Aborting."
. "$(dirname "$0")"/common.sh
# 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")":/out.tar.gz \
--rm "$UBUNTU_IMAGE" \
tar -czpf /out.tar.gz -C / var/lib/postgresql/data var/lib/overview/searchindex var/lib/overview/blob-storage