Skip to content

Instantly share code, notes, and snippets.

@radityopw
Last active April 3, 2018 03:02
Show Gist options
  • Save radityopw/1f70791f2231ce7a8dd0b7bf71854058 to your computer and use it in GitHub Desktop.
Save radityopw/1f70791f2231ce7a8dd0b7bf71854058 to your computer and use it in GitHub Desktop.
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