dev-scripts/scripts/export-wp.sh

30 lines
646 B
Bash
Raw Permalink 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
2020-09-05 13:04:21 +00:00
ssh -T $ssh << EOSSH
cd "$wp_path"
2020-09-05 11:27:45 +00:00
wp db export \
--path="$wp_path" \
--dbuser="$wp_db_user" \
--dbpass="$wp_db_pass" \
--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
2020-09-05 13:04:21 +00:00
scp "$ssh:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
scp "$ssh:/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 << EOSSH
rm "/tmp/$_db_filename"
rm "/tmp/$_archive_filename"
2020-09-05 11:27:45 +00:00
EOSSH