PHP backup tool for FreeBSD

The last weeks I have used many hours working on my good old server Ingelin, my HTTP (this page among others), POP3, SMTP, FTP, CVS server.
Some years ago, when I first installed it I wrote a simple PHP script that executed a series of commands to burn a CD-RW with critical data. Some days ago i figured I had to rewrite it, in order for it to suit my needs:


< ?php
// let's get on with this.. :o
$DIR['tmp']="/usr/backup_tmp";
$DIR['backup']="/usr/backup";

$targets=array(
'apache_config' => "/usr/local/etc/apache",
);

/**
* Make nice archives
*/

while(list($name,$path)=each($targets)) {
exec("tar --gzip --create --absolute-names --preserve --file ".$DIR['tmp']."/".$name.".tgz ".$path);
}

/**
* Burn CD!
*/
exec("/usr/local/bin/mkisofs -quiet -L -l -allow-lowercase -allow-multidot -N -v -d -o ".$DIR['backup']."/backup.iso ".$DIR['tmp']." > /dev/null 2>&1");
exec("/usr/sbin/burncd -q -f /dev/acd0c -q blank");
exec("/usr/sbin/burncd -q -f /dev/acd0c -s 6 data ".$DIR['backup']."/backup.iso fixate");

$fileSize=`ls -ls $DIR[tmp]`;
$imageSize=`du -h $DIR[backup]/backup.iso`;

/**
* Remove files
*/
exec("rm -rf ".$DIR['tmp']."/*");
exec("rm -f ".$DIR['backup']."/backup.iso");

mail("root", "ingelin.xqus.com: Backup","
Backup finished.

----------------------------------------------------
".$fileSize." ".trim($imageSize)."
----------------------------------------------------

", "From: backup@ingelin.xqus.com");
?>

Tags:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><pre><blockquote>
  • Lines and paragraphs break automatically.
  • Insert Flickr images: [flickr-photo:id=230452326,size=s] or [flickr-photoset:id=72157594262419167,size=m].

More information about formatting options