Compare commits
3 Commits
8997df6327
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
062c764c9b | ||
|
|
c5716b8f7a | ||
|
|
7331fcf2d0 |
20
backup.sh
20
backup.sh
@@ -10,11 +10,14 @@ set -a
|
||||
. "${PWD}/.env"
|
||||
set +a
|
||||
|
||||
now="$(date +%Y-%m_%d-%H-%M-%S)"
|
||||
docker compose stop
|
||||
|
||||
now="$(date +%Y-%m-%d_%H-%M-%S)"
|
||||
backup_path="${PWD}/backup-volumes/${now}"
|
||||
mkdir -p "${backup_path}"
|
||||
|
||||
volumes="db root traefik-dynamic traefik-certs traefik-logs traefik-static webroot"
|
||||
volumes="db"
|
||||
for volume in ${volumes}; do
|
||||
mkdir -p "${backup_path}/${volume}"
|
||||
docker run \
|
||||
@@ -25,9 +28,24 @@ for volume in ${volumes}; do
|
||||
tar -cvzf "/destination/${volume}.tar.gz" -C "/${volume}" .
|
||||
done
|
||||
|
||||
docker compose restart db
|
||||
docker compose restart app
|
||||
while ! docker ps -q -f name="${PREFIX}-db"; do
|
||||
echo "Waiting for the db container to be up and running..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
while ! docker exec "${PREFIX}-app" /bin/sh -c "mysqladmin ping -h ${PREFIX}-db -P 3306 --protocol=tcp -u user -puser --silent"; do
|
||||
echo "Waiting for the mysql server in the db container to be up and running and reachable from the app container..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
mkdir -p "${backup_path}/db"
|
||||
docker exec "${PREFIX}-db" \
|
||||
/usr/bin/mysqldump \
|
||||
-u root \
|
||||
--password="${DB_ROOT_PASSWORD}" \
|
||||
"${DB_NAME}" > "${backup_path}/db/${DB_NAME}.sql"
|
||||
|
||||
docker compose stop db
|
||||
docker compose stop app
|
||||
|
||||
35
check-diff.sh
Normal file
35
check-diff.sh
Normal file
@@ -0,0 +1,35 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
|
||||
set -x
|
||||
if [ "$#" -eq 0 ] || [ "$#" -gt 1 ]; then
|
||||
echo takes only one argument
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${1}" ]; then
|
||||
echo cannot find "${1}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck source=./env_files/checkdiff-example.env
|
||||
. "${1}"
|
||||
|
||||
remote_copy_path=$(mktemp -d)
|
||||
rsync \
|
||||
--archive \
|
||||
--checksum \
|
||||
--human-readable \
|
||||
"${REMOTE_SSH_STRING}":"${REMOTE_ROOT_PATH}${FOLDER_PATH}/" \
|
||||
"${remote_copy_path}"
|
||||
|
||||
local_copy_path=$(mktemp -d)
|
||||
rsync \
|
||||
--archive \
|
||||
--checksum \
|
||||
--exclude-from="${EXCLUDEFILE_PATH}" \
|
||||
--human-readable \
|
||||
"${LOCAL_ROOT_PATH}${FOLDER_PATH}/" \
|
||||
"${local_copy_path}"
|
||||
|
||||
kdiff3 "${local_copy_path}" "${remote_copy_path}"
|
||||
@@ -78,24 +78,31 @@ services:
|
||||
- traefik-logs:/logs
|
||||
- traefik-static:/etc/traefik/static:ro
|
||||
|
||||
version: "3.4"
|
||||
|
||||
volumes:
|
||||
cache:
|
||||
external: true
|
||||
name: composer-cache
|
||||
db:
|
||||
external: true
|
||||
name: ${PREFIX}-db
|
||||
root:
|
||||
external: true
|
||||
name: ${PREFIX}-root
|
||||
traefik-certs:
|
||||
external: true
|
||||
name: ${PREFIX}-traefik-certs
|
||||
traefik-dynamic:
|
||||
external: true
|
||||
name: ${PREFIX}-traefik-dynamic
|
||||
traefik-logs:
|
||||
external: true
|
||||
name: ${PREFIX}-traefik-logs
|
||||
traefik-static:
|
||||
external: true
|
||||
name: ${PREFIX}-traefik-static
|
||||
webroot:
|
||||
external: true
|
||||
name: ${PREFIX}-webroot
|
||||
wp-cli-cache:
|
||||
external: true
|
||||
name: wp-cli-cache
|
||||
|
||||
5
env_files/checkdiff-example.env
Normal file
5
env_files/checkdiff-example.env
Normal file
@@ -0,0 +1,5 @@
|
||||
REMOTE_SSH_STRING=<sshconfig hostname>
|
||||
REMOTE_ROOT_PATH=</var/www/example.com/www>
|
||||
LOCAL_ROOT_PATH=</home/user/dev/www>
|
||||
FOLDER_PATH=</wp-content/themes/bar>
|
||||
EXCLUDEFILE_PATH=<./deployment/example.com.bar.exclude>
|
||||
Reference in New Issue
Block a user