Risultati da 21 a 30 di 34
-
25-04-2005, 21:38 #21
- Data Registrazione
- Apr 2005
- Messaggi
- 129
Originariamente Scritto da mossss
-
18-09-2005, 12:05 #22
una funzione che c'è sempre stata ma ho 'scoperto' solo ora...
è ottimale per me che ho una flat ma lenta e non posso tenere bloccato il forum per ore.
in ACP => Importa & Manutenzione => Backup DB selezionate le tabelle che volete backuppare e poi Backup database in un file sul server
è una cosa interessantissima che mi ha permesso di fare l'intero backup (400MB) in soli 5 min
e poi me lo scarico tranquillamente quando voglio dal servermossss
OnlyFocus.com
Discussioni: 9,236, Messaggi: 493,085, Utenti: 2,011
powered by vBulletin 3.6.0 + vBadvanced CMPS 2.2 + Coppermine Gallery v1.4.8
Vi prego di NON mandare email/PM per chiedere supporto, usate il forum!!!
-
18-09-2005, 15:14 #23
In vb.org c'è un hack che fa il backup in automatico e decidi tu il giorno e l'ora
jancarlo
-
18-09-2005, 18:51 #24
Al posto del hack è meglio creare un cron (script php) e chiamarlo da vbulletin. Oppure, meglio, chiamare uno script in asincrono dal phpinclude_end:
Codice PHP:session_start();
if(!$_SESSION['cronjob_done'])
{
ob_start();
$fs = fsockopen('www.sito.com', 80, $errno, $errstr, 5);
if($fs)
{
fwrite($fs, "GET /cron/cronjobs.php HTTP/1.0\r\n"
. "Host: www.sito.com\r\n\r\n");
}
ob_end_clean();
$_SESSION['cronjob_done'] = TRUE;
}
Giovanni
http://www.trimelli.com/
Per favore non mandatemi PM, ma scrivete sul forum. Vi sarà risposto prima.
-
19-09-2005, 14:33 #25
Giovanni potresti passare tutto il necessario per fare ciò che dici? Sarebbe molto utile...
graziemossss
OnlyFocus.com
Discussioni: 9,236, Messaggi: 493,085, Utenti: 2,011
powered by vBulletin 3.6.0 + vBadvanced CMPS 2.2 + Coppermine Gallery v1.4.8
Vi prego di NON mandare email/PM per chiedere supporto, usate il forum!!!
-
20-09-2005, 01:12 #26
cronjobs.php (1)
Codice PHP:<?php
/*******************************************************************************
* (C) Copyright Y2K Software s.a.s. 2005 *
* All Rights Reserved *
********************************************************************************
* Realtime Cronjobs *
* Require to run without error reporting nor locks or messages (blank pages). *
* All scripts must reside in the same folder and require to set $cron_ok to *
* TRUE if successful. *
* The database is already open so there is no need to repeat opening. *
* Also cron scripts should not open a session or use common functions or *
* variables. *
* Cronjobs should test if $cron_jobs = TRUE, else do nothing. *
*******************************************************************************/
error_reporting(0);
ignore_user_abort(TRUE); // continue script if session quits
$DEBUG = FALSE;
//$DEBUG = TRUE;
$cron_jobs = TRUE;
$time_limit = 10; // in seconds, 0 = no limit
// Functions -------------------------------------------------------------------
function cron_db_open()
{
$db = 0;
$db_host = 'localhost';
$db_name = 'database_name';
$db_username = 'username';
$db_password = 'password';
$db_port = 3306;
$host = $db_host;
if($db_port && $db_port != 3306)
{
$host = "$db_host:$db_port";
}
if(mysql_connect($host, $db_username, $db_password))
{
return mysql_select_db($db_name);
}
}
function cron_iif($var, $true, $false = '')
{
return $var ? $true : $false;
}
function cron_datadump($table)
{
$result .= "# Dump of `$table`\r\n"
. "# Dump DATE: " . date("Y-m-d H:i:s") . "\r\n"
. "\r\n"
;
$rss = mysql_query("SELECT * FROM $table");
$num_fields = @mysql_num_fields($rss);
while($rs = mysql_fetch_row($rss))
{
$result .= "INSERT INTO `$table` VALUES (";
for($j = 0; $j < $num_fields; $j++)
{
$a = addslashes($rs[$j]);
$a = ereg_replace("\r", "\\r", $a);
$a = ereg_replace("\n", "\\n", $a);
$result .= "'$a'";
$result .= $j < $num_fields - 1 ? ', ' : '';
}
$result .= ");\r\n";
}
return $result . "\r\n\r\n";
}
// BEGIN OF SCRIPT =============================================================
// Open database ---------------------------------------------------------------
while(cron_db_open()) // pseudo-loop
{
// Check if cronjob is running ---------------------------------------------
$SQL = "UPDATE service "
. "SET VALUE='1' "
. "WHERE PARAMETER='INCRON' "
. "AND VALUE='0' "
. "LIMIT 1"
;
if(!mysql_query($SQL)) break;
if(!mysql_affected_rows()) break;
// Open cronjob table ------------------------------------------------------
$SQL = "SELECT ID, SCRIPT "
. "FROM cron "
. "WHERE ENABLED=1 "
. "AND DATE<=NOW() "
. "AND SECS>0 "
. "ORDER BY EXECORDER"
;
if(!$rss_cron = mysql_query($SQL)) break;
// Cycle cronjobs ------------------------------------------------------
while($rs_cron = mysql_fetch_row($rss_cron))
{
// Set max execution time ------------------------------------------
set_time_limit($time_limit);
$cron_ok = FALSE;
$lastops = 0;
if($DEBUG)
{
echo $rs_cron[1];
}
// Check for cronjob file ------------------------------------------
if(file_exists($rs_cron[1]))
{
require_once($rs_cron[1]);
if($cron_ok)
{
// Update null dates ---------------------------------------
$SQL = "UPDATE cron "
. "SET DATE=CURDATE(), "
. "LASTOPS = $lastops "
. "WHERE ID=$rs_cron[0] "
. "AND DATE='0000-00-00 00:00:00' "
. "LIMIT 1"
;
if(mysql_query($SQL))
{
// Update cycle until DATE>NOW() ---------------------------
$SQL = "UPDATE cron "
. "SET DATE=DATE_ADD(DATE, INTERVAL SECS SECOND), "
. "LASTOPS = $lastops "
. "WHERE ID=$rs_cron[0] "
. "AND DATE<=NOW() "
. "LIMIT 1"
;
// Repeat until updated ------------------------------------
do
{
mysql_query($SQL);
} while(mysql_affected_rows() > 0);
}
}
}
if($DEBUG)
{
echo $cron_ok ? ' <b>OK</b><BR>' : " <b>Error</b><BR>";
}
}
// Enable cronjobs again ---------------------------------------------------
$SQL = "UPDATE service "
. "SET VALUE='0' "
. "WHERE PARAMETER='INCRON' "
. "LIMIT 1"
;
mysql_query($SQL);
break;
}
unset($cron_jobs);
// END OF SCRIPT ===============================================================
?>Giovanni
http://www.trimelli.com/
Per favore non mandatemi PM, ma scrivete sul forum. Vi sarà risposto prima.
-
20-09-2005, 01:17 #27
cron_bkp_forum.php (2)
Codice PHP:<?php
/*******************************************************************************
* (C) Copyright Y2K Software s.a.s. 2005 *
* All Rights Reserved *
********************************************************************************
* Realtime Cronjob: Database backup for vb3_* tables (forum) *
*******************************************************************************/
// BEGIN OF SCRIPT =============================================================
while($cron_jobs) // pseudo-loop
{
// Backup ------------------------------------------------------------------
$vbfiledata = '';
if(!$rss = mysql_list_tables('database_name')) break;
while($rs = mysql_fetch_row($rss))
{
if(substr($rs[0], 0, 4) == 'vb3_')
{
$vbfiledata .= cron_datadump($rs[0]);
$lastops++;
}
}
mysql_free_result($rss);
/*
$message = "This is a backup created by a script on your site.\r\n"
. "The location of the script is " . __FILE__ . ".\r\n"
;
if($vbfiledata)
{
$filename = date("Y-m-d_H-i-s") . "_vb3_database_name.sql.gz";
$vbfiledata = gzencode($vbfiledata, 9);
$mail = new xmail();
$mail->from = $from_email;
$mail->to = 'admin@domain.com';
$mail->subject = "Forums database backup";
$mail->xpriority = 1;
$mail->body = $message;
$mail->add_attachment($vbfiledata, $filename, 'application/x-zip-compressed', 'base64');
$vbfiledata = '';
$mail->send();
}
*/
$cron_ok = TRUE;
break;
}
// END OF SCRIPT ===============================================================
?>, o pagate
Giovanni
http://www.trimelli.com/
Per favore non mandatemi PM, ma scrivete sul forum. Vi sarà risposto prima.
-
20-09-2005, 01:20 #28
Tabella cron (non vbulletin!) (3)
Codice PHP:# --------------------------------------------------------
#
# Struttura della tabella `cron`
#
DROP TABLE IF EXISTS `cron`;
CREATE TABLE `cron` (
`ID` int(11) NOT NULL auto_increment,
`ENABLED` tinyint(1) NOT NULL default '0',
`DATE` datetime NOT NULL default '0000-00-00 00:00:00',
`SECS` int(11) NOT NULL default '3600',
`DESCRIPTION` varchar(255) NOT NULL default '',
`SCRIPT` varchar(255) NOT NULL default '',
`EXECORDER` int(11) NOT NULL default '0',
`LASTOPS` int(11) NOT NULL default '0',
PRIMARY KEY (`ID`)
) TYPE=MyISAM;
Giovanni
http://www.trimelli.com/
Per favore non mandatemi PM, ma scrivete sul forum. Vi sarà risposto prima.
-
20-09-2005, 01:49 #29
Eccovi il plugin (anziché hack) al vbulletin, e/o altre applicazioni php. Il tutto funziona alla meraviglia, se il safe-mode è OFF. Se invece è attivo, il timeout viene ignorato, e quindi bisogna accertarsi che il backup esegue a un'ora che è meno battuta, ma che vi sia comunque qualcuno.
Lo script esegue nel background, quindi l'utente non nota alcuna differenza.
Attenzione però: Se uno degli script va in loop, perché non vi sia alcun timeout + uno o più errori di programmazione, si consumano tutte le risorse del server, e l'unico modo per uscirci è riavviarlo. Per utenti che non hanno un proprio server, un loop del genere può significare una violazione del contratto all'ISP e si rischia un'ammonizione severa, se non addirittura la chiusura dell'account.
Il timeout va impostato a un valore in cui si è sicuri che il backup vada a buon termine. 10 secondi è buono per un database fino a 5 MB su un server veloce, dove lo zip prende il tempo maggiore.
Consiglio inoltre di usare il file system per gli allegati ed avatar, per ridurre le dimensioni.
Il mailer non è allegato qui, perché mi ci voleva troppo tempo per farlo, in modo che funzioni bene e (quasi) ovunque (php 4.3.10+), e di conseguenza è soltanto in vendita (ca. 50 euretti fatturabili). L'idea ho copiata, ma il codice è tutto mio, perché, come sappiamo tutti, gli esempi freeware non funzionano praticamente mai...Giovanni
http://www.trimelli.com/
Per favore non mandatemi PM, ma scrivete sul forum. Vi sarà risposto prima.
-
23-10-2005, 12:27 #30
grande giovanni...
ma che serve sto mailer?
il mio db è su aruba e pesa circa 220MB, a quanti secondi lo dovrei impostare?mossss
OnlyFocus.com
Discussioni: 9,236, Messaggi: 493,085, Utenti: 2,011
powered by vBulletin 3.6.0 + vBadvanced CMPS 2.2 + Coppermine Gallery v1.4.8
Vi prego di NON mandare email/PM per chiedere supporto, usate il forum!!!
Segnalibri