<?PHP/** * WarpedCoders - Backup Utility * ------------------------------ * Thanks to daga and netfish for some ideas they provided me with. */$conf = array();$conf['limit'] = 30; // Set the current backup allow limit.$conf['time'] = time(); // Current TimeStamp for backup files.$conf['folder'] = "/home/skarecrow/www"; // The folder that will be backed up.$conf['backup'] = "/home/skarecrow/backup"; // The folder where the files will be backed up to.generateBackup();checksum();/** * Generates the backup file to a timestamp.tar * Allows us to work with the file. * -------------------------------------------- * Function will also call the checksum function. */function generateBackup() { global $conf; exec("tar -cvf {$conf['backup']}/{$conf['time']}.tar {$conf['folder']}");}/** * Gets the current checksum of the backup created. * If the sum is different then the privous backup then we update our sum for the next update. * Else the sum has not changed so we delete the backup. */function checksum() { global $conf; $currentSum = file_get_contents($conf['backup']."/chksum.txt"); $sum = exec("md5sum {$conf['backup']}/{$conf['time']}.tar"); $sum = explode(" ", $sum); $sum = $sum[0]; if ($sum != $currentSum) { update($sum); } else { exec("rm {$conf['backup']}/{$conf['time']}.tar"); }}/** * Update the last backup checksum. * Used to see if any changes have been made. */function update($sum) { global $conf; $file = fopen("{$conf['backup']}/chksum.txt", "w+"); fputs($file, $sum); fclose($file);}?>