Backup Data RotorCMS
1.
KareelKun (28.11.2010 / 15:30)
Share backup data mysql rotorcms!
2.
mozzzg (28.11.2010 / 17:33)
while only with help phpmyadmin
3.
Славик (28.11.2010 / 18:03)
<?php
define ("FILES_TO_KEEP", 5);
define ("BACKUP_PERIOD", 86400); // сутки
define ("DATABASE_CONF", 'mysql://mysql_login:mysql_password@mysql_server/database_name');
define ("BACKUP_FOLDER", './backup' );
error_reporting(0);
function cmp_file_times($t1, $t2) {
if ($t1['t'] == $t2['t']) return 0;
return ($t1['t'] > $t2['t']) ? 1 : -1;
}
function backup() {
global $now;
$file = BACKUP_FOLDER."/backup-".date("d-m-Y_H-i-s", $now).".sql";
$db = parse_url(DATABASE_CONF);
$db['path'] = substr($db['path'], 1);
$q = "mysqldump -u".$db['user']." -p".$db['pass']." -h".$db['host']." ".$db['path']." > ";
exec($q.$file."; gzip -f ".$file); // убедитесь что функции "mysqldump" и "gzip" доступны в консоли.
}
$now = time();
clearstatcache();
$b_dir = dir(BACKUP_FOLDER);
$b_files = array();
while($file = $b_dir->read()) {
if (preg_match("/^backup-(\d+)-(\d+)-(\d+)_(\d+)-(\d+)-(\d+)/i", $file, $a)) {
array_push($b_files, array('n' => $file, 't' => mktime($a[4], $a[5], $a[6], $a[2], $a[1], $a[3])));
}
}
$b_dir->close();
$b_count_files = count($b_files);
if ($b_count_files) {
usort($b_files, "cmp_file_times");
if ($b_files[$b_count_files - 1]['t'] <= $now - BACKUP_PERIOD) {
if ($b_count_files >= FILES_TO_KEEP) {
for ($i = 0; $i < $b_count_files - FILES_TO_KEEP + 1; $i ++) {
unlink(BACKUP_FOLDER."/".$b_files[$i]['n']);
}
}
backup();
}
}else {
backup();
}
?>
4.
hugo (29.11.2010 / 15:04)
Zip code php please
5.
hugo (08.12.2010 / 10:47)
Please write code in php
6.
Удаленный (08.12.2010 / 14:16)
please .zip code
7.
hugo (09.12.2010 / 04:05)
I need write in php please
8.
nybiru (10.12.2010 / 06:38)
up@ what N70 not support copy paste??
9.
hugo (22.12.2010 / 16:43)
Not run php script
URL:
https://visavi.net/topics/15996