-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestore_script.sh
More file actions
57 lines (47 loc) · 1.47 KB
/
restore_script.sh
File metadata and controls
57 lines (47 loc) · 1.47 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
#!/bin/bash
help() {
cat << EOF
Usage: restore_script.sh <wiki|redmine|mattermost> <filepath to sqlc backup>
Restore a PostgreSQL database for Wiki.js, Redmine, and Mattermost
POSTGRES BACKUP LOCATIONS:
- Wiki.js: /opt/docker-apps/wiki/backup/_postgres
- Redmine: /opt/docker-apps/redmine/backup
- Mattermost: /opt/docker-apps/mattermost/backup
EXAMPLE:
restore_script.sh wiki /opt/docker-apps/wiki/backup/_postgres/wiki-backup-2024-06-06.04:00:02.sqlc
EOF
}
restore() {
echo "container: ${container}"
echo "dbuser: ${dbuser}"
echo "database: ${database}"
echo "filepath: ${filepath}"
echo "docker exec -i $(docker ps -aqf "name=^postgres-${container}$") /usr/local/bin/pg_restore -U ${dbuser} -d ${database} -1 --clean --verbose --no-acl --no-owner < ${filepath}"
}
filepath=$2
case $1 in
wiki)
echo "Restoring Wiki.js database"
container="wiki"
dbuser="wiki"
database="wiki"
restore
;;
redmine)
echo "Restoring Redmine"
container="redmine"
dbuser="redmine"
database="redmine"
restore
;;
mattermost)
echo "Restoring Mattermost..."
container="mattermost"
dbuser="mmuser"
database="mattermost"
restore
;;
*)
help
;;
esac