Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. /home/myname/dobackups
  2.  
  3. <?php
  4. $cpaneluser = 'userhere'; // cPanel username
  5. $cpaneluserpass = 'userpasshere'; // cPanel password
  6. $theme = 'paper_lantern'; // Must match current selected cPanel theme ('paper_lantern' in the majority of cases, 'x3' is possible as well)
  7. $ftp = true; // If it's false the backup will be stored in user's home directory, otherwise it will be uploaded via FTP to some custom location
  8. $ftpserver = 'serverX.web-hosting.com'; // Must be localhost for current server or custom hostname for remote FTP upload
  9. $ftpusername = 'userftp'; // cPanel/SFTP username. Should be the same as cPanel username for local upload or custom for remote upload
  10. $ftppassword = 'ftppass'; // cPanel/SFTP password. Should be the same as cPanel password for local upload or custom for remote upload
  11. $ftpport = '21098'; // SFTP port. Should be 21 in most cases.
  12. $ftpdirectory = '/home2/user/DatabaseBackups'; // Directory on FTP server to store backups. MUST EXIST BEFORE BACKUP OR BACKUP PROCESS WILL FAIL
  13. // Do not edit below this line
  14. $domain = 'localhost';
  15. $secure = true;
  16. $auth = base64_encode($cpaneluser . ":" . $cpaneluserpass);
  17. if ($secure) {
  18. $url = "ssl://" . $domain;
  19. $port = 2083;
  20. } else {
  21. $url = $domain;
  22. $port = 2082;
  23. }
  24. $socket = fsockopen('localhost', 2082);
  25. if (!$socket) {
  26. exit("Failed to open socket connection.");
  27. }
  28. if ($ftp) {
  29. $params = "dest=scp&server=$ftpserver&user=$ftpusername&pass=$ftppassword&port=$ftpport&rdir=$ftpdirectory&submit=Generate Backup";
  30. } else {
  31. $params = "submit=Generate Backup";
  32. }
  33. fputs($socket, "POST /frontend/" . $theme . "/backup/dofullbackup.html?" . $params . " HTTP/1.0rn");
  34. fputs($socket, "Host: $domainrn");
  35. fputs($socket, "Authorization: Basic $authrn");
  36. fputs($socket, "Connection: Closern");
  37. fputs($socket, "rn");
  38. while (!feof($socket)) {
  39. $response = fgets($socket, 4096);
  40. // echo $response; //uncomment this line for debugging
  41. }
  42. fclose($socket);
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement