View Single Post
  #1   (View Single Post)  
Old 15th January 2010
bgobs bgobs is offline
Port Guard
 
Join Date: Jun 2008
Location: Sofia, BG
Posts: 17
Default Request for sh script for compressing files

I need bash script to backup my sites. Something like this:

(I dont know very well english so I'll try to explain myself with PHP )

Code:
$date = date("m-Y-");
$sitesPath = "/some/path/to/web/sites/";
if (is_dir($sitesPath)) {
	$handle = opendir($sitesPath);
	if (!empty($handle)) {
		while (false !== ($file = readdir($handle))) {
			if (is_dir($sitesPath.$file)) { $dir_array[] = $file; }
		}
		
	}
	closedir($handle);
}


if (is_array($dir_array)) {
	foreach ($dir_array as $dir) {
		echo "Archiving: ".$sitesPath."/".$dir."<br />";
		exec("tar -zcvf ".$date."-".$dir.".tar.gz ".$sitesPath."/".$dir);
	}
}
Can someone write bash script for me and for free? just for my deep dark brown eyes ?

And of course sorry for my english

Thanks for reading !
__________________
FreeBSD 6.2 RELEASE
Reply With Quote