restore.sh 688 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. echo "Connect server successful"
  3. echo "Website need restore:"
  4. read domain
  5. while [ ! -d /home/*/$domain ]; do
  6. echo "$domain not found, please try again"
  7. read domain
  8. done
  9. #Delete data old
  10. rm -rf /home/*/$domain/DocumentRoot
  11. config=/home/*/$domain/wp-config.php
  12. user=$(grep DB_USER $config | awk -F\' '{print$4}')
  13. db=$(grep DB_NAME $config | awk -F\' '{print$4}')
  14. pass=$(grep DB_PASSWORD $config | awk -F\' '{print$4}')
  15. tar -xf backup.tar.gz
  16. mv -f */DocumentRoot/ /home/*/$domain/
  17. mysql -u $user -p$pass $db < backup.sql
  18. if [ "$?" -eq 0 ] ; then
  19. echo "======================================="
  20. echo "Restore successful"
  21. rm -rf /home/*/backup
  22. else
  23. echo "Restore fail"
  24. fi