From 7c1a0bbcf244dfcc5c5f6c10d452eecf5374d7a0 Mon Sep 17 00:00:00 2001 From: Glenn Date: Wed, 10 Jul 2024 16:02:16 +0200 Subject: [PATCH] Initial import --- README.md | 0 dokku-sync.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 README.md create mode 100644 dokku-sync.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/dokku-sync.sh b/dokku-sync.sh new file mode 100644 index 0000000..a54b109 --- /dev/null +++ b/dokku-sync.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# vim: set ts=2 sw=2 et: + +set -e +set -u + +LOCAL="danaos.infra.glenux.net" +REMOTE="dinlas.infra.glenux.net" +SSH_REMOTE="root@$REMOTE" +SSH_KEY="$HOME/.ssh/dinlas-to-danaos_rsync2022_ed25519" + +sshrun() { + ssh -i "$SSH_KEY" root@dinlas.infra.glenux.net "$*" +} + +# mkdir -p /srv/backup +# APPS=$ (sshrun "dokku ls" |awk '/^[^--]/ { print $1; }') + +# Stop all remote services +sshrun "dokku ps:stop --all" + +sshrun "dokku mariadb:list |tail -n+2 |xargs -iSERVICE -- dokku mariadb:stop SERVICE" +sshrun "dokku postgres:list |tail -n+2 |xargs -iSERVICE -- dokku postgres:stop SERVICE" +sshrun "dokku redis:list |tail -n+2 |xargs -iSERVICE -- dokku redis:stop SERVICE" +sshrun "dokku mongo:list |tail -n+2 |xargs -iSERVICE -- dokku mongo:stop SERVICE" + +sshrun "systemctl stop docker" +sshrun "systemctl stop docker.socket" + + +# Stop all local services +dokku ps:stop --all +systemctl stop docker +systemctl stop docker.socket + +# Copy all data +mkdir -p /home/dokku/ +mkdir -p /home/data/ +mkdir -p /var/lib/dokku/ + +rsync -avz --delete "$SSH_REMOTE:/home/dokku/" /home/dokku/ +rsync -avz --delete "$SSH_REMOTE:/var/lib/dokku/" /var/lib/dokku/ +rsync -avz --delete "$SSH_REMOTE:/home/data/" /home/data/ +rsync -avz --delete "$SSH_REMOTE:/home/git/" /home/git/ + +# Start all local services +dokku apps:list + +# Patch URLs from imported domains +find /home/dokku/ -name VHOST -or -name URLS \ + | xargs -iFILE -- \ + sed -i "s/$REMOTE/$LOCAL/g" FILE + +echo "SUCCESS"