add database backup to restore

This commit is contained in:
Ray Elliott 2020-09-13 21:34:25 +01:00
parent eebea4ce0d
commit 7e1701bc1f
1 changed files with 7 additions and 4 deletions

View File

@ -8,12 +8,15 @@ backup_dir="$1"
echo "restoring from $backup_dir"
backup_dest="/tmp/wp-content-$(date +%s)"
ssh "$remote_ssh" "mv $remote_wp_path/wp-content $backup_dest"
echo "remote wp-content backed up as: $backup_dest"
backup_db_dest="/tmp/wp-content-$(date +%s)"
ssh "$remote_ssh" "mv $remote_wp_path/wp-content $backup_db_dest"
echo "remote wp-content backed up as: $backup_db_dest"
cat "$backup_dir/$backup_dir.tar" | ssh "$remote_ssh" "cd /; tar zxvf -"
# TODO - backup database first?
# 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" -
wp search-replace "$local_protocol://$local_domain" "$remote_protocol://$remote_domain" \