From 0e526b24544c1c5ae41419f9d4e81ca8fed7e9c0 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 10 Sep 2020 10:45:44 +0100 Subject: [PATCH] add backup script --- tools/wp-content-db/backup.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 tools/wp-content-db/backup.sh diff --git a/tools/wp-content-db/backup.sh b/tools/wp-content-db/backup.sh new file mode 100755 index 0000000..ae3717a --- /dev/null +++ b/tools/wp-content-db/backup.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +. ./config + +time="$(date +%s)" +[ -n "$1" ] && base_filename="$1-$time" || base_filename="backup-$time" + +echo "backing up to $base_filename" + +ssh "$remote_ssh" mkdir "/tmp/$base_filename" +ssh "$remote_ssh" tar -cvzf "/tmp/$base_filename/$base_filename.tar" "$remote_wp_path/wp-content" +wp db export "/tmp/$base_filename/$base_filename.sql" --ssh="$remote_ssh$remote_wp_path" --add-drop-table + +scp -r "$remote_ssh:/tmp/$base_filename" . && ssh "$remote_ssh" rm -r "/tmp/$base_filename"