dev-scripts/scripts/export-wp.sh

30 lines
646 B
Bash
Executable File

#!/bin/sh
echo "Exporting from $url .."
_timestamp="$(date +%s)"
_db_filename="wordpress-$_timestamp.db"
_archive_filename="wordpress-$_timestamp.tar.gz"
_local_dest_dir="./data/$_target"
ssh -T $ssh << EOSSH
cd "$wp_path"
wp db export \
--path="$wp_path" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--add-drop-table \
--allow-root \
"/tmp/$_db_filename"
tar czf "/tmp/$_archive_filename" "$wp_path"
EOSSH
scp "$ssh:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
scp "$ssh:/tmp/$_db_filename" "$_local_dest_dir/$_db_filename"
exit
ssh -T $ssh << EOSSH
rm "/tmp/$_db_filename"
rm "/tmp/$_archive_filename"
EOSSH