Skip to content

Instantly share code, notes, and snippets.

@wolinka
Last active July 26, 2021 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolinka/e6ef2d7ab59077436c56b24b124de7d4 to your computer and use it in GitHub Desktop.
Save wolinka/e6ef2d7ab59077436c56b24b124de7d4 to your computer and use it in GitHub Desktop.
<?php
// Bu komut dosyasi, Cpanel yedeginizi otomatik olarak belli zaman araliklarinda ya farkli bir sunucuya ya da kendi ftp sunucunuza yedek aldirir.
// Guvenlik acisindan public_html ya da www dizinlerinde bu dosyayi bulundurmayiniz.
// Bu komut dosyasi, https://gist.github.com/nikhgupta/1071596 adresinden alinti yapilarak cozum uretilmistir.
// Cpanel Erisimi Icin Gerekli Bilgiler
$cpuser = "cpanel_kullanici_adi"; // Cpanel'e giris yapmak icin kullanilan kullanici adi
$cppass = "cpanel_sifre"; // Cpanel'e giris yapmak icin kullanilan sifre
$domain = "siteadi.com"; // Yedeklemesini yapmak istediginiz domain adi
$skin = "paper_lantern"; // Cpanel icin kullanilan tema adi. Guncel surumlerde "paper_lantern" temasi kullanilmaktadir. Eger eski versiyon cpanel kullaniyorsaniz "x" kullanilabilir. Cpanel tema secimi onemlidir, aksi halde script calismaz.
// FTP Erisimi Icin Gerekli Bilgiler
$ftpuser = "ftp_kullanici_adi"; // Ftp ile giris yapmak icin kullanilan kullanici adi
$ftppass = "ftp_sifre"; // Ftp ile giris yapmak icin kullanilan sifre
$ftphost = "ftp.siteadi.com"; // Site FTP adresi ya da IP adresi
$ftpmode = "homedir"; // Yedegin gonderilecegi yer (kendi hostinginizde yedekleme yapmak icin "homedir", uzak ftp sunucusuna gondermek icin "passiveftp" kullanilabilir)
$ftpport = "21"; // Port (Varsayilan = 21)
$rdir = "/"; // Yedekleme yapilacak dizin (Varsayilan = / )
// Bildirim Ayarlari
$notifyemail = "you@example.com"; // Sonuclarin gonderilecegi email adresi
// Secure or non-secure mode
$secure = 0; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP
// Set to 1 to have web page result appear in your cron log
$debug = 0;
// *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********
if ($secure) {
$url = "ssl://".$domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;
}
$socket = fsockopen($url,$port);
if (!$socket) { echo "Failed to open socket connection… Bailing out!\n"; exit; }
// Encode authentication string
$authstr = $cpuser.":".$cppass;
$pass = base64_encode($authstr);
$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$rdir&submit=Generate Backup";
// Make POST to cPanel
fputs($socket,"POST /frontend/".$skin."/backup/fullbackup.html?".$params." HTTP/1.0\r\n");
fputs($socket,"Host: $domain\r\n");
fputs($socket,"Authorization: Basic $pass\r\n");
fputs($socket,"Connection: Close\r\n");
fputs($socket,"\r\n");
// Grab response even if we don't do anything with it.
while (!feof($socket)) {
$response = fgets($socket,4096);
if ($debug) echo $response;
}
fclose($socket);
?>
@omerkymcu
Copy link

thank you dude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment