@GOTO START
<?php
### embedded php in bat (batch) script.
$backup_path = 'D:/Backup/php_script';
$current_path = getcwd();
$current_folder = basename($current_path);
$backup_path = $backup_path . '/' . $current_folder;
### Checks whether the backup path exists. Create it if not exist.
if (!file_exists($backup_path)) {
mkdir($backup_path);
}
$now = date("ymd_his");
$tarFileName = $now . '_' . $current_folder . '.rar';
### where to store tar file.
$tarFilePath = $backup_path . '/' . $tarFileName;
// ### We have ever encountered a situation that, if the current folder name begins with "script*",
// ### then, error msg box will be pop-up.
// ### So, we added following line to fix the problem.
$tarFilePath = str_replace('/', '\\', $tarFilePath);
### specify a list of filename / folder name, separating by space.
//$listFiles = 'drupal-6.10_dev drupal-6.9_Danny drupal-6.9_Karl';
$listFiles = '*';
echo "Please Wait . . . Be patient ^_<\n";
// ### Ignoring folders that begin with ".svn"
$cmd = '"C:\\Program Files\\WinRAR\\WinRAR.exe"' . ' a ' . $tarFilePath . ' -x*\.svn* -r ' . $listFiles;
exec($cmd);
echo "Done :)\n" . $cmd;
/*
:START
@d:\uo\www\PHP5.2.9\php.exe %0
@pause
@exit
*/
?>
Wednesday, September 2, 2009
Use batch and PHP script WinRAR to backup files folders under current folder
backupFiles_v3.bat
Subscribe to:
Post Comments (Atom)
1 comment:
great article, but I prefer the combination of backups and recovery services, have you ever heard about the service of sql database recovery, provided by Recovery Toolbox for SQL Server? Indeed, it is not possible to write a separate article for all database-related issues
Post a Comment