k3rn3lp4n1c

Untitled

May 30th, 2020
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.35 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ -f ~/.ssh/id.rsa ]; then
  4.     echo "                                                            
  5. _|_|_|      _|_|      _|_|_|  _|    _|  _|    _|  _|_|_|    
  6. _|    _|  _|    _|  _|        _|    _|  _|    _|  _|    _|  
  7. _|_|_|    _|_|_|_|    _|_|    _|_|_|_|  _|    _|  _|_|_|    
  8. _|    _|  _|    _|        _|  _|    _|  _|    _|  _|        
  9. _|_|_|    _|    _|  _|_|_|    _|    _|    _|_|    _|        
  10.                                                            
  11.                                         by k3rn3l0l
  12.  
  13.     Vesta2'@panel_name' migration script
  14.  
  15.     This script upload all sites backups to remote server
  16. "
  17. read -p 'Enter backup server username' us3r
  18. read -p 'Enter backup server IP' ip4ddr
  19. dirct='/home/admin/web'
  20. sitelist=$(ls "$dirct")
  21. for word in $sitelist
  22. do
  23. sitepath="$dirct"/"$word"/public_html
  24. mysqldump -u $(grep DB_USER $sitepath/wp-config.php | cut -d "'" -f 4) -p$(grep DB_PASSWORD "$sitepath"/wp-config.php | cut -d "'" -f 4) $(grep DB_NAME "$sitepath"/wp-config.php | cut -d "'" -f 4) > "$sitepath"/"$word".sql
  25. tar czvf "$dirct"/"$word" "$word".tar.gz
  26. scp "$word".tar.gz "$us3r"@"$ip4ddr":~/
  27. done
  28. else
  29.     echo "This script make all sites backups and upload archives to remote server, but installed ssh-key is required."
  30.     echo "For install this key, enter this commands:"
  31.     echo "ssh-keygen"
  32.     echo "ssh-copy-id <user>@<ipaddress>"
  33.     exit 1
  34. fi
Add Comment
Please, Sign In to add comment