33 lines
770 B
Bash
Executable File
33 lines
770 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"
|
|
|
|
# check we have ssh access
|
|
[ -z "$ssh_user" ] && echo "Error: no user ssh configuration specified" && exit 5
|
|
|
|
ssh -T $ssh_user << EOSSH
|
|
cd "$wp_path"
|
|
wp db export \
|
|
--path="$wp_path" \
|
|
--dbuser="$db_user" \
|
|
--dbpass="$db_pass" \
|
|
--add-drop-table \
|
|
--allow-root \
|
|
"/tmp/$_db_filename"
|
|
tar czf "/tmp/$_archive_filename" "$wp_path"
|
|
EOSSH
|
|
|
|
scp "$ssh_user:/tmp/$_archive_filename" "$_local_dest_dir/$_archive_filename"
|
|
scp "$ssh_user:/tmp/$_db_filename" "$_local_dest_dir/$_db_filename"
|
|
|
|
exit
|
|
ssh -T $ssh_user << EOSSH
|
|
rm "/tmp/$_db_filename"
|
|
rm "/tmp/$_archive_filename"
|
|
EOSSH
|