Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 1015 Bytes

bash-database-sync.md

File metadata and controls

33 lines (24 loc) · 1015 Bytes

Synchronize Remote Databases

Sync Down

#!/usr/bin/env bash

echo "Optimizing Remote Database..."
ssh -C [email protected] "cd ~/site.com/current && php artisan telescope:clear"

echo "Synchronizing Local with Remote..."
ssh -C [email protected] "mysqldump --default-character-set=utf8mb4 staging" | mysql staging
echo "Staging Synchronized to Local Successfully."

ssh -C [email protected] "mysqldump --default-character-set=utf8mb4 production" | mysql production
echo "Production Synchronized to Local Successfully."

Sync Up

#!/usr/bin/env bash

echo "Optimizing Local Database..."
php artisan telescope:clear

echo "Synchronizing Remote with Local..."
mysqldump staging | ssh -C [email protected] "mysql staging"
echo "Staging Synchronized to Remote Successfully."

echo "Writing to Production Remote is Forbidden!  Nice Try Gangsta. UnComment if you dare!"
#mysqldump production | ssh -C [email protected] "mysql production"
#echo "Production Synchronized to Remote Successfully."