dev-scripts/scripts/export-wp.sh

33 lines
770 B
Bash
Raw Normal View History

2020-09-05 11:27:45 +00:00
#!/bin/sh
2020-09-05 13:04:21 +00:00
echo "Exporting from $url .."
2020-09-05 11:27:45 +00:00
2020-09-05 13:04:21 +00:00
_timestamp="$(date +%s)"
_db_filename="wordpress-$_timestamp.db"
_archive_filename="wordpress-$_timestamp.tar.gz"
_local_dest_dir="./data/$_target"
2020-09-05 11:27:45 +00:00
# check we have ssh access
[ -z "$ssh_user" ] && echo "Error: no user ssh configuration specified" && exit 5
ssh -T $ssh_user << EOSSH
2020-09-05 13:04:21 +00:00
cd "$wp_path"
2020-09-05 11:27:45 +00:00
wp db export \
--path="$wp_path" \
2020-09-08 17:24:06 +00:00
--dbuser="$db_user" \
--dbpass="$db_pass" \
2020-09-05 11:27:45 +00:00
--add-drop-table \
--allow-root \
2020-09-05 13:04:21 +00:00
"/tmp/$_db_filename"
tar czf "/tmp/$_archive_filename" "$wp_path"
2020-09-05 11:27:45 +00:00
EOSSH
scp "$ssh_user:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
scp "$ssh_user:/tmp/$_db_filename" "$_local_dest_dir/$_db_filename"
2020-09-05 11:27:45 +00:00
2020-09-05 13:04:21 +00:00
exit
ssh -T $ssh_user << EOSSH
2020-09-05 13:04:21 +00:00
rm "/tmp/$_db_filename"
rm "/tmp/$_archive_filename"
2020-09-05 11:27:45 +00:00
EOSSH