Skip to content
Permalink
Browse files

πŸ“¦ NEW: Remote script `db-backup`

  • Loading branch information...
austinginder committed Aug 23, 2019
1 parent f962440 commit 2040f1ddd86c43b75c4142c3dc70a138a9d3d3ac
Showing with 16 additions and 2 deletions.
  1. +6 βˆ’2 app/backup
  2. +10 βˆ’0 lib/remote-scripts/db-backup
@@ -115,7 +115,7 @@ run_command() {

# Database backup (if remote server available)
if [[ "$provider" == "kinsta" ]] || [[ "$provider" == "wpengine" ]]; then
captaincore ssh $site --command="wp db export --skip-plugins --skip-themes --add-drop-table --default-character-set=utf8mb4 - > wp-content/mysql.sql; chmod 600 wp-content/mysql.sql" --captain_id=$captain_id
captaincore ssh $site --script="db-backup" --captain_id=$captain_id
fi

fi
@@ -176,8 +176,12 @@ run_command() {
wp post meta update $id visits_staging "$visits"
fi

if [[ "$captaincore_dev" == true ]]; then
curl_argument="-k"
fi

# Post folder size bytes and yearly visits to ACF fields
curl --request POST "$captaincore_api" --header "Content-Type: application/json" --data @- << EOF
curl ${curl_argument} --request POST "$captaincore_api" --header "Content-Type: application/json" --data @- << EOF
{
"command":"usage-update",
"site_id":"$site_id",
@@ -0,0 +1,10 @@
# get the wp-config.php variables
DBNAME=$(grep DB_NAME wp-config.php | awk -F "'" '{print $4}')
DBUSER=$(grep DB_USER wp-config.php | awk -F "'" '{print $4}')
DBPASS=$(grep DB_PASS wp-config.php | awk -F "'" '{print $4}')

# Perform DB backup with [emoji support](https://anchor.host/wp-cli-database-backups-with-emojis/) and [speed](https://guides.wp-bullet.com/how-to-export-large-wordpress-databases-and-speed-up-the-process/)
mysqldump -u ${DBUSER} -p${DBPASS} --default-character-set=utf8mb4 --add-drop-table --single-transaction --quick --lock-tables=false ${DBNAME} > wp-content/mysql.sql

# Make it safe
chmod 600 wp-content/mysql.sql

0 comments on commit 2040f1d

Please sign in to comment.
You can’t perform that action at this time.