Wednesday, March 4, 2015

Auto back up files, using php


This code zip all the files from /var/www/* and move it to /root/backups/


$back_from = '/var/www/*';
$back_to = '/root/backups/';
$files = glob($back_to."*.zip",GLOB_BRACE);
echo $cmd = 'zip -r '.$back_to.date("Y-m-d").'.zip '.$back_from."\n";
shell_exec($cmd);
if(count($files) > 1){
foreach($files as $item){
$file_zip = str_replace($back_to,"",$item);
$file_date = trim($file_zip, ".zip")."\n";
$check_date = date('Y-m-d', strtotime(date("Y-m-d"). ' - 5 days')); //delete file older then 6 days before
if($file_date < $check_date ){
$rm_old = 'rm -rf '.$back_to.$file_zip;
shell_exec($rm_old);
}
}
}

CSS tricks

Mixed paint in background: background: linear-gradient(to right, #b6e358, #38b143) Grid view: display: grid; grid-template-columns: a...