versionecologique/synchro.sh

29 lines
1.2 KiB
Bash
Raw Normal View History

2017-06-16 14:55:51 +02:00
#!/bin/bash
clear
2017-07-11 15:32:15 +02:00
## NO MORE DB UPDATES ON THE PREPROD ##
2017-06-16 14:55:51 +02:00
#Dump local database
2017-07-11 15:32:15 +02:00
echo "Exporting the local Database"
2017-06-16 14:55:51 +02:00
mysqldump -h 192.168.0.41 -u root versionecologique > versionecologique.sql
printf "Export complete => file versionecologique.sql has been created\n"
2017-07-11 15:32:15 +02:00
printf "Replacing shop names\n"
2017-06-16 14:55:51 +02:00
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 \\
2017-07-12 09:37:16 +02:00
&& mkdir -p /home/www/versionecologique.preprod.antadis.fr/www/{log,upload} \\
2017-06-16 14:55:51 +02:00
&& chown -R www-data:www-data www/* \\
"
2017-07-11 15:32:15 +02:00
printf "Sync complete !! \n"