-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
47 lines (34 loc) · 1.58 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
# ------------------------------------------------------------------------------
# docker-entrypoint.sh
# ------------------------------------------------------------------------------
# This script prepares backup files locally that can be used by the wordpress
# tool to restore to a copy of the website running on the desktop. It sources
# the files from a run of the "WordPress - Restore" tool.
# ------
# Validate that the SUBDOMAIN and DOMAIN environment variables have been
# provided.
if [[ -z "${SUBDOMAIN}" ]]; then
echo \
'You must set the SUBDOMAIN environment variable using the ' \
'"-e KEY=VAL" argument to the docker-compose command2'
exit
else
if [[ -z "${DOMAIN}" ]]; then
echo \
'You must set the DOMAIN environment variable for the ' \
'wp-make-backup service in your docker-compose.yml file'
fi
fi
# Copy the restored files locally.
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-r hub:/tmp/bacula-restores/wp-sites/${SUBDOMAIN}.${DOMAIN}/. .
# Tar and/or zip the files.
gzip -cvf $(ls *.sql) > database.sql.gz
tar -czvf html.tar.gz html
# Remove the local copy of original files prior to the tar and/or zip.
rm -rf html
rm $(ls *.sql)
# Remove the restored files from the hub host.
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null hub << EOF
sudo rm -rf /tmp/bacula-restores/wp-sites/${SUBDOMAIN}.${DOMAIN}
EOF