Closed marcbth closed 5 years ago
backup.php
`<?php $from = "/mnt/hdd/B"; $to = "/media/usb0/Backup"; $skip = array('some_file.php', 'somedir'); copy_r($from, $to, $skip);
function copy_r($from, $to, $skip=false) { global $skip; $dir = opendir($from); if (!file_exists($to)) {mkdir ($to, 0775, true);} while (false !== ($file = readdir($dir))) { if ($file == '.' OR $file == '..' OR in_array($file, $skip)) {continue;}
if (is_dir($from . DIRECTORY_SEPARATOR . $file)) {
copy_r($from . DIRECTORY_SEPARATOR . $file, $to . DIRECTORY_SEPARATOR . $file);
}
else {
copy($from . DIRECTORY_SEPARATOR . $file, $to . DIRECTORY_SEPARATOR . $file);
}
}
closedir($dir);
exec ("find /media/usb0 -type d -exec chmod 0777 {} +"); exec ("find /media/usb0 -type f -exec chmod 0777 {} +");
}
//$creport = 'Backup OK'; // echo '';
header('Location: index.php'); exit;
?>
`
Hello Artur,
I added a menu item in settings.
backup.
solved very simply at the moment, maybe as a suggestion:
/usr/bin/local/fullbackup.sh
! / Bin / bash
/ usr / bin / rsync -aHXrtv --del --modify-window = 2 / mnt / hdd / media / usb0
force sync of files to disk before unmounting
/ Bin / sync
unmount the backup disk
/ bin / umount / media / usb0
or via php
backup.php
<? Php $ from = "/ mnt / hdd /"; $ to = "/ media / usb0 /"; $ skip = array ('some_file.php', 'somedir'); copy_r ($ from, $ to, $ skip);
function copy_r ($ from, $ to, $ skip = false) { global $ skip; $ dir = opendir ($ from); if (! file_exists ($ to)) {mkdir ($ to, 0775, true);} while (false! == ($ file = readdir ($ dir))) { if ($ file == '.' OR $ file == '..' OR in_array ($ file, $ skip)) {continue;}
if (is_dir ($ from. DIRECTORY_SEPARATOR. $ file)) { copy_r ($ from. DIRECTORY_SEPARATOR. $ file, $ to. DIRECTORY_SEPARATOR. $ file); } else { copy ($ from. DIRECTORY_SEPARATOR. $ file, $ to. DIRECTORY_SEPARATOR. $ file); } } closedir ($ dir); exec ("find / media / usb0 -type d -exec chmod 0777 {} +"); exec ("find / media / usb0 -type f -exec chmod 0777 {} +") } </ Script> ';
header ('Location: index.php'); exit;
?>
Unfortunately, without indication of progress.
Many thanks for your effort
cliff
can I donate something?