GNU/Linux >> Linux Esercitazione >  >> Panels >> cPanel

Come impostare backup automatici

Come impostare backup automatici

Utilizzando lo script fornito di seguito sarai in grado di eseguire backup cPanel completi automatici del tuo account.

Questo script di backup include il supporto SSL. Questo non è necessario se esegui lo script sul server per il quale stai generando il backup, ma il supporto SSL potrebbe essere importante se stai eseguendo lo script da qualche altra parte per connetterti al tuo account di hosting cPanel.

<?php
$cpaneluser = 'user'; // cPanel username $cpaneluserpass = 'pass'; // cPanel password $theme = 'paper_lantern'; // Must match current selected cPanel theme ('paper_lantern' in the majority of cases, 'x3' is possible as well) $ftp = true; // Needs to be enabled for the backup to be uploaded to your Namecheap or third-party server; do NOT change the value $ftpserver = 'serverX.web-hosting.com'; // Must be 'localhost' for current server or custom hostname for remote FTP upload $ftpusername = 'user'; // cPanel/SFTP username. Should be the same as cPanel username for local upload or custom for remote upload $ftppassword = 'pass'; // cPanel/SFTP password. Should be the same as cPanel password for local upload or custom for remote upload $ftpport = '21098'; // SFTP port. Should be 21 in most cases. $ftpdirectory = '/home/'.$cpaneluser.'/backups'; // Directory on FTP server to store backups. MUST EXIST BEFORE BACKUP OR BACKUP PROCESS WILL FAIL. Also, make sure ot update the 'cpaneluser' part with your current cPanel username. // Do not edit below this line $domain = 'localhost'; $secure = true; $auth = base64_encode($cpaneluser . ":" . $cpaneluserpass); if ($secure) { $url = "ssl://" . $domain; $port = 2083; } else { $url = $domain; $port = 2082; } $socket = fsockopen('localhost', 2082); if (!$socket) { exit("Failed to open socket connection."); } if ($ftp) { $params = "dest=scp&server=$ftpserver&user=$ftpusername&pass=$ftppassword&port=$ftpport&rdir=$ftpdirectory&submit=Generate Backup"; } else { $params = "submit=Generate Backup"; } fputs($socket, "POST /frontend/" . $theme . "/backup/dofullbackup.html?" . $params . " HTTP/1.0\r\n"); fputs($socket, "Host: $domain\r\n"); fputs($socket, "Authorization: Basic $auth\r\n"); fputs($socket, "Connection: Close\r\n"); fputs($socket, "\r\n"); while (!feof($socket)) { $response = fgets($socket, 4096); // echo $response; //uncomment this line for debugging } fclose($socket);?>

NOTA :assicurati di sostituire l'utente e la password di cPanel con i tuoi dati.

Per programmare l'esecuzione regolare dello script, salvalo come fullbackup.php nella tua home directory e aggiungi un nuovo processo cron con la seguente sintassi:

00 2 * * 1 /usr/local/bin/php /home/youraccount/fullbackup.php
(viene eseguito ogni lunedì sera alle 2:00 am)

Per escludere la cartella dei backup dalla generazione automatica del backup (se il tuo account è grande un paio di GB, l'utilizzo dello spazio su disco aumenterà drasticamente , poiché ogni nuovo backup conterrà tutti i precedenti), cerca il file cpbackup-exclude.conf nella home directory, aggiungi il nome della cartella e usa un asterisco * dopo la directory se vuoi escludere tutti i file da una directory oppure aggiungi il percorso del file che desideri escludere dai backup e salva le modifiche.
NOTA :Se non è presente un file cpbackup-exclude.conf nella home directory, è necessario crearne uno manualmente.


NOTE :
  • Se il tuo account è ospitato su un server condiviso, assicurati che l'utilizzo dello script sia ottimizzato per non sovraccaricare il server.
  • Non forniamo servizi di debug del codice. Questo script viene fornito solo a titolo di cortesia per tua comodità.

Se disponi di un hosting Premium o aziendale, è possibile gestire backup completi di cPanel utilizzando il plug-in cPanel di AutoBackup.



                   Hai bisogno di aiuto? Contattaci tramite l'Helpdesk





cPanel
  1. Come configurare gli inoltri di posta elettronica

  2. Come impostare gli aggiornamenti automatici su Debian

  3. Come impostare la modalità notturna automatica in Ubuntu 20.04?

  4. Come impostare una voce MX in cPanel

  5. Come impostare l'inoltro web

Come configurare AutoSSL sul tuo dominio

Come impostare un IP statico su Debian 11

Come impostare un Cron Job in cPanel

Come impostare un indirizzo predefinito in cPanel

Come impostare un Autoresponder in cPanel

Come configurare Memcached in cPanel