sufehmi

Wordpress Auto-Backup via SSH

Feb 18th, 2018 (edited)
2,366
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.48 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # wordpress-auto-backup.sh
  4.  
  5. ### THIS SCRIPT ASSUMES THE FOLLOWING
  6. # 1/ You can do SSH password-less login to the server
  7. #   How : https://easyengine.io/tutorials/linux/passwordless-authentication-ssh/
  8. # 2/ You have created a correct ~/.my.cnf file
  9. #   How : https://easyengine.io/tutorials/mysql/mycnf-preference/
  10.  
  11. ### RUNTIME PARAMETERS
  12. # wordpress-auto-backup.sh  <server address> <home directory> <backup directory>
  13.  
  14. ### HOW IT WORKS
  15. # 1/ SSH to server
  16. # 2/ read wp-config file & get details
  17. # 3/ create backup_dir/web
  18. # 4/ rsync home_dir backup_dir/web
  19. # 5/ backup database to backup_dir/web/today.mysql
  20. # 6/ compress backup_dir/web to backup_dir/backup_today.bz2
  21.  
  22. ### choose backup retention
  23. # backup retention: weekly
  24. today=`date +%A`
  25. # backup retention: monthly
  26. #today=`date +%d`
  27.  
  28. timestamp=`date +%H-%M-%S`
  29.  
  30. compressor1='gzip'
  31. compressor2='pbzip2'
  32.  
  33. # to help making this code more readable
  34. server=$1
  35. home_dir=$2
  36. backup_dir=$3
  37. ssh_user=$4
  38. website=$5
  39.  
  40. #============= START BACKUP =======================
  41.  
  42. # get the variables
  43. ssh $ssh_user@$server "cat $home_dir/wp-config.php" > /tmp/$server$today$timestamp.txt
  44.  
  45. db_name=`cat /tmp/$server$today.txt | grep DB_NAME | cut -d"'" -f 4`
  46. db_user=`cat /tmp/$server$today.txt | grep DB_USER | cut -d"'" -f 4`
  47. db_pass=`cat /tmp/$server$today.txt | grep DB_PASSWORD | cut -d"'" -f 4`
  48. db_host=`cat /tmp/$server$today.txt | grep DB_HOST | cut -d"'" -f 4`
  49. table_prefix=''
  50. table_prefix=`cat /tmp/$server$today$timestamp.txt | grep table_prefix | cut -d"'" -f 2`
  51. # debug
  52. #echo $db_name $db_user $db_pass $db_host $table_prefix
  53.  
  54.  
  55. # delete temporary file
  56. rm /tmp/$server$today$timestamp.txt
  57.  
  58. # backup database
  59. ssh  $ssh_user@$server "mysqldump -h $db_host  -u $db_user --no-tablespaces --password=\"$db_pass\"  $db_name \$(mysql -h $db_host -u $db_user --password=\"$db_pass\" -D $db_name  -Bse \"show tables like '$table_prefix%'\") > $home_dir/db-$today.mysql"
  60.  
  61. # compress database dump
  62. ssh  $ssh_user@$server "$compressor1 -f $home_dir/db-$today.mysql"
  63.  
  64. # download everything
  65. mkdir -p $backup_dir/web/
  66. rsync -avuz $ssh_user@$server:$home_dir/* $backup_dir/web/
  67.  
  68. # make backup file
  69. tar cvf $backup_dir/$website-$today.tar $backup_dir/web/
  70. # remote clean up
  71. ssh $ssh_user@$server "rm $home_dir/db-$today.mysql.gz" &
  72. # compress backup
  73. $compressor2 -f $backup_dir/$website-$today.tar
  74. # local clean up
  75. rm $backup_dir/web/db-$today.mysql.gz
  76.  
  77. ### check
  78. #ls -l $backup_dir/web
  79. #ls -l $backup_dir
  80.  
  81. # done !
  82.  
  83.  
Advertisement
Comments
  • User was banned
  • GhostSTG
    95 days
    Comment was deleted
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • hson_8mi6
    50 days
    # CSS 0.28 KB | 0 0
    1. ⭐ New 0-day PoC posted today by The Protocol One group.
    2.  
    3. Interesting stuff, made $520 with this in like 30 minutes
    4.  
    5. PoC Documentation: https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    6.  
    7. Original Post: https://t.me/theprotocolone/48
  • Ravsutan
    48 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • User was banned
Add Comment
Please, Sign In to add comment