add export data script

This commit is contained in:
Ray Elliott 2020-03-08 17:18:47 +00:00
parent 0d89401112
commit f2a8210a35
1 changed files with 20 additions and 0 deletions

20
dev/export-data.sh Normal file
View File

@ -0,0 +1,20 @@
#!/bin/sh
if [ -z "$1" ] ; then
echo "Must supply container name as argument"
exit 1
fi
. ./config
_host="$1.home"
_cmd_wp_export="wp db export --dbuser=wordpress --dbpass=$_wp_db_passwd --add-drop-table data.sql"
_ssh_cmd="sshpass -p$_passwd_www ssh $_user_www@$_host"
_scp_cmd="sshpass -p$_passwd_www scp $_user_www@$_host:/tmp/wordpress.tar.gz"
$_ssh_cmd "cd /var/www/html/wordpress &&" $cmd_wp_export
$_ssh_cmd 'cd /var/www/html/wordpress && tar czf /tmp/wordpress.tar.gz .'
$_ssh_cmd "rm /var/www/html/wordpress/data.sql"
$_scp_cmd "."
$_ssh_cmd 'rm /tmp/wordpress.tar.gz'