backup
Для вордпресса есть хороший плагин, который делает бэкап раз в час, день неделю, это уж как настроить, и есть возможность отсылки его на мыло. Решил сделать такое же для phpbb3, не плагин конечно, а так скриптик. Вот что получилось:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/acp/acp_database.' . $phpEx);
include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
$time = time();
$filename = 'backup_' . $time . '_' . unique_id();
$mail = 'backup@mail.com';
$subj = 'backup';
$tables = get_tables($db);
$ext = new mysql_extractor(false, true, 'gzip', $filename, $time);
$ext->write_start($table_prefix);
foreach ($tables as $table_name){
$ext->write_table($table_name);
$ext->write_data($table_name);
}
$ext->write_end();
//send mail
$path = $phpbb_root_path . 'store/' . $filename . '.sql.gz';
$boundary = "==PHPBB-BY-VAMPIRUS-".md5(time());
$fp = fopen($path,"rb");
$file = fread($fp,filesize($path));
fclose($fp);
$data = chunk_split(base64_encode($file));
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary="$boundary"\n";
$headers .= 'From: vampirus@site.ru'. "\n";
$message = "blabla\nThis is a multi-part message in MIME format.\n\n" .
"--{$boundary}\n" .
"Content-Type: text/plain; charset=koi8-r\n" .
"Content-Transfer-Encoding: 8bit\n\n" .
"backup\n\n";
$message .= "--{$boundary}\n" .
"Content-Type: application/octet-stream;\n" .
" name="{$filename}.sql.gz"\n" .
"Content-Disposition: attachment;\n" .
" filename="{$filename}.sql.gz"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$boundary}--\n";
mail($mail,$subj,$message,$headers);
unlink($path);
?>
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/acp/acp_database.' . $phpEx);
include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
$time = time();
$filename = 'backup_' . $time . '_' . unique_id();
$mail = 'backup@mail.com';
$subj = 'backup';
$tables = get_tables($db);
$ext = new mysql_extractor(false, true, 'gzip', $filename, $time);
$ext->write_start($table_prefix);
foreach ($tables as $table_name){
$ext->write_table($table_name);
$ext->write_data($table_name);
}
$ext->write_end();
//send mail
$path = $phpbb_root_path . 'store/' . $filename . '.sql.gz';
$boundary = "==PHPBB-BY-VAMPIRUS-".md5(time());
$fp = fopen($path,"rb");
$file = fread($fp,filesize($path));
fclose($fp);
$data = chunk_split(base64_encode($file));
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary="$boundary"\n";
$headers .= 'From: vampirus@site.ru'. "\n";
$message = "blabla\nThis is a multi-part message in MIME format.\n\n" .
"--{$boundary}\n" .
"Content-Type: text/plain; charset=koi8-r\n" .
"Content-Transfer-Encoding: 8bit\n\n" .
"backup\n\n";
$message .= "--{$boundary}\n" .
"Content-Type: application/octet-stream;\n" .
" name="{$filename}.sql.gz"\n" .
"Content-Disposition: attachment;\n" .
" filename="{$filename}.sql.gz"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$boundary}--\n";
mail($mail,$subj,$message,$headers);
unlink($path);
?>
естественно на хосте должно быть установлено расширение zlib для php.
Осталось теперь только в cron задание добавить. Бэкапы шлуются на мыло на гмэйле, помойму самый лучший вариант).