Tempat Data
13May/102

Backup Website otomatis menggunakan script PHP, cPanel dan FTP

Berikut ini script PHP untuk melakukan proses backup website menggunakan cPanel dan FTP. Proses backup tersebut bisa dijalankan secara otomatis, dengan menambahkan script tersebut di crontab (Linux) atau schedule task (Windows).

Silahkan Download script di bawah ini, dan edit/update parameter sesuai dengan data cPanel dan FTP yang sesuai :

  • $sites['1']['cpuser'] :  Username cPanel
  • $sites['1']['cppass'] : Password cPanel
  • $sites['1']['domain'] : Domain di cPanel
  • $sites['1']['skin'] : Jenis skin cPanel yang digunakan (script tidak akan berjalan jika tidak cocok)
  • $ftpuser : Username FTP di tempatdata.com
  • $ftppass :  Password FTP di tempatdata.com
  • $ftphost : ftp.tempatdata.com
  • $ftpmode : ftp
  • $ftpdir = /username-data
  • $notifyemail : Email-address untuk notifikasi ketika proses backup selesai.
<?php// PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.

// This script contains passwords.  KEEP ACCESS TO THIS FILE SECURE! (place it in your home dir, not /www/)

// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********

// Info required for cPanel access

// Domain 1

$sites['1']['cpuser'] = "username1"; // Username used to login to CPanel

$sites['1']['cppass'] = "password1"; // Password used to login to CPanel

$sites['1']['domain'] = "domain1.com"; // Domain name where CPanel is run

$sites['1']['skin'] = "x"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme

// Domain 2

$sites['2']['cpuser'] = "username2";

$sites['2']['cppass'] = "password2";

$sites['2']['domain'] = "domain2.com";

$sites['2']['skin'] = "rvlightblue";

// Domain 3

$sites['3']['cpuser'] = "username3";

$sites['3']['cppass'] = "password3";

$sites['3']['domain'] = "domain3.com";

$sites['3']['skin'] = "x3";

// Info required for FTP host

$ftpuser = "username"; // Username for FTP account

$ftppass = "password"; // Password for FTP account

$ftphost = "ftp.domain.com"; // Full hostname or IP address for FTP host

$ftpmode = "scp"; // FTP mode ("ftp" for active, "passiveftp" for passive, or "scp" for scp - most secure)

$ftpdir = ''/username-data"; // Directory to save the files in

// Notification information

$notifyemail = "youremail@example.com"; // Email address to send results

// Secure or non-secure mode

$secure = 1; // 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 *********

foreach ($sites as $site) {

if ($secure) {

$url = "ssl://".$site['domain'];

$port = 2083;

} else {

$url = $site['domain'];

$port = 2082;

}

$socket = fsockopen($url,$port);

if (!$socket) { echo "Failed to open socket connection… Bailing out!\n"; exit; }

// Encode authentication string

$authstr = $site['cpuser'].":".$site['cppass'];

$pass = base64_encode($authstr);

$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=&rdir=$ftpdir&submit=Generate Backup";

// Make POST to cPanel

fputs($socket,"POST /frontend/".$site['skin']."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");

fputs($socket,"Host: {$site['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;

}

echo "\nDone with {$site['domain']}\n";

fclose($socket);

}

?>

Kategori : FTP Kirim Komentar
Komentar (2) Trackback (0)
  1. bingung aku, gimana sih cara simpan data ? kelihatan rumit sekali.
    harus mulai dari mana?

    kalau saya mau upload dokumen dari laptop saya dan disimpan di tempatdata.com bisa gak ?

  2. anda bisa upload dokumen apa saja ke tempatdata.com
    salah satu caranya dengan menggunakan fasilitas webdav di windows xp/2003, coba akses ke link berikut :
    http://www.tempatdata.com/?p=1
    atau dengan FTP, coba akses ke link berikut :
    http://www.tempatdata.com/?p=344#owner


Kirim komentar

Silahkan login untuk mengirim komentar.

Belum ada trackback.