Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
script untuk generate transaction log sqlserver dari list file yang ada di folder
<?php
/*
asumsi adalah nama trans log adalah *.trn
asumsi lain adalah nama log file melambangkan waktu dicreate nya , nama sudah terurut
*/
$dir = $argv[1]."\\*.trn";
$dbname = $argv[2];
$files = glob($dir);
foreach($files as $f){
echo "RESTORE LOG [$dbname] FROM DISK = N'$f' WITH NORECOVERY\r\n";
echo "GO\r\n";
}
echo "RESTORE DATABASE [$dbname] WITH RECOVERY\r\n";
echo "GO\r\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment