From f2a8210a351a3ac5be17087b077de3e6c5776bb1 Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 8 Mar 2020 17:18:47 +0000 Subject: [PATCH] add export data script --- dev/export-data.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 dev/export-data.sh diff --git a/dev/export-data.sh b/dev/export-data.sh new file mode 100644 index 0000000..be1efbd --- /dev/null +++ b/dev/export-data.sh @@ -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'