versionecologique/synchro.sh

28 lines
1.1 KiB
Bash
Raw Normal View History

2017-06-16 14:55:51 +02:00
#!/bin/bash
clear
## NO MOE DB UPDATES ON THE PREPROD ##
#Dump local database
echo "exporting the local Database"
mysqldump -h 192.168.0.41 -u root versionecologique > versionecologique.sql
printf "Export complete => file versionecologique.sql has been created\n"
printf "replacing shop names\n"
sed -i -e 's/versionecologique.local/versionecologique.preprod.antadis.fr/g' versionecologique.sql
printf "Sending the Database dump to the preprod server"
PORT="4096"
rsync -e "ssh -p$PORT" -az ./versionecologique.sql root@versionecologique.preprod.antadis.fr:/home/www/versionecologique.preprod.antadis.fr
printf "Sending complete\n"
#printf "importing the Database on the preprod server\n"
ssh root@versionecologique.preprod.antadis.fr -p4096 "cd /home/www/versionecologique.preprod.antadis.fr \\
&& git pull origin master \\
&& mysql -u versionecologique -pShoh5Re5 versionecologique < versionecologique.sql \\
&& if [ -f /home/www/versionecologique.preprod.antadis.fr/www/cache/class_index.php ] ; then rm /home/www/versionecologique.preprod.antadis.fr/www/cache/class_index.php ; fi \\
&& chown -R www-data:www-data www/* \\
"
printf "sync complete !! \n"