add backup script

This commit is contained in:
Ray Elliott 2020-09-10 10:45:44 +01:00
parent b2e95eb294
commit 0e526b2454
1 changed files with 14 additions and 0 deletions

14
tools/wp-content-db/backup.sh Executable file
View File

@ -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"