From dc8ae701f28e3e9a7a75f6c108289bace5648df4 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 16 Jan 2024 17:28:29 +0100 Subject: [PATCH] Greatly upgrade dbbackup.sh with more verbosity and allow setting the server with the 2nd param --- bin/bin/blbackup | 4 +--- bin/bin/dbbackup.sh | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/bin/blbackup b/bin/bin/blbackup index 83e8aae..d0bfb4e 100755 --- a/bin/bin/blbackup +++ b/bin/bin/blbackup @@ -1,7 +1,5 @@ #/bin/sh -name=$(ssh www-data@simalia 'cd dbmanager && ./bin/console db:backup bles' | awk -F'-|\\.def' '{split($1,a," ")}$0=a[4]') -scp -C www-data@simalia:/var/www/dbmanager/${name} ~/projects/dbmanager -cd ~/projects/dbmanager && ./bin/console db:purge bles && ./bin/console db:restore bles ${name} +dbbackup.sh bles simalia scp -Cr www-data@simalia:/var/www/bles.bluelinked.nl/shared/public/uploads/images/ ~/projects/bles/public/uploads/ diff --git a/bin/bin/dbbackup.sh b/bin/bin/dbbackup.sh index e4d2339..2445eb3 100755 --- a/bin/bin/dbbackup.sh +++ b/bin/bin/dbbackup.sh @@ -1,8 +1,16 @@ #/bin/sh database=$1 -command="cd dbmanager && ./bin/console db:backup ${database}" +server=$2 -name=$(ssh www-data@cemophora "${command}" | awk -F'-|\\.def' '{split($1,a," ")}$0=a[4]') -scp -C www-data@cemophora:/var/www/dbmanager/${name} ~/projects/dbmanager -cd ~/projects/dbmanager && ./bin/console db:purge ${database} && ./bin/console db:restore ${database} ${name} +echo "Backing up ${database}@${server}" +command="cd dbmanager && ./bin/console db:backup ${database}" +name=$(ssh www-data@${server} "${command}" | awk -F'-|\\.def' '{split($1,a," ")}$0=a[4]') +echo "Backup filename: ${name}" + +local_dir="$HOME/projects/dbmanager" +echo "Copying ${name} to ${local_dir}" +scp -C www-data@${server}:/var/www/dbmanager/${name} "${local_dir}" + +echo "Purging and restoring back to ${database}" +cd ${local_dir} && ./bin/console db:purge ${database} && ./bin/console db:restore ${database} ${name}