From 04c0fb169e0b04349d187ad025e270d2ba25f0bf Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 13 Sep 2020 21:37:32 +0100 Subject: [PATCH] tidy up --- tools/wp-content-db/restore.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/wp-content-db/restore.sh b/tools/wp-content-db/restore.sh index 1885735..d9e2fff 100755 --- a/tools/wp-content-db/restore.sh +++ b/tools/wp-content-db/restore.sh @@ -4,17 +4,19 @@ [ -z "$1" ] && echo "Error - must supply backup directory" && exit 45 ! [ -d "$1" ] && echo "Error - '$1' not a directory" && exit 65 + backup_dir="$1" +timestamp="$(date +%s)" +backup_dir_dest="/tmp/wp-content-$timestamp" +backup_db_dest="/tmp/wp-db-$timestamp" echo "restoring from $backup_dir" -backup_dir_dest="/tmp/wp-content-$(date +%s)" ssh "$remote_ssh" "mv $remote_wp_path/wp-content $backup_dir_dest" echo "remote wp-content backed up as: $backup_dir_dest" cat "$backup_dir/$backup_dir.tar" | ssh "$remote_ssh" "cd /; tar zxvf -" # TODO - test database backup works -backup_db_dest="/tmp/wp-db-$(date +%s)" ssh "$remote_ssh" "wp db export $backup_db_dest --path=$remote_wp_path" echo "remote database backed up as: $backup_db_dest" cat "./$backup_dir/$backup_dir.sql" | wp db import --ssh="$remote_ssh$remote_wp_path" -