[Mssqlcompressed-users] mssqlcompressed with powershellscript
Brought to you by:
xclayl
|
From: Otis L. <oti...@go...> - 2009-12-15 16:05:36
|
Hi all,
now i have integrated the msbp.exe in a litle powershellscript, which
the taskplaner starts every night:
powershell.exe D:\DB-Dumps\MSSQLCompressedBackup\BackupScriptForDBs.ps1
- so, that i have a backupserie from a whole week, maybe, that
somebody could make use of this litle script.
function BackupFolder
{
param( [object] $objSrcFolder, [object] $objDstFolder)
$strSrcFolder = $objSrcFolder.Path
$strDstFolder = $objDstFolder.Path
$colSrcFiles = $objSrcFolder.Files
$colDstFiles = $objDstFolder.Files
$ActualDay = (get-date).dayofweek.toString() + "_"
#after backing up the database - rename the logfile and db-zip
with the actual days
foreach ($objSrcFile in $colSrcFiles)
{
Rename-Item ($strSrcFolder + "\" + $objSrcFile.Name)
-NewName ($ActualDay + $objSrcFile.Name )
}
#move it from the db-server to another storagelocation in the intranet
foreach ($objSrcFile in $colSrcFiles)
{
move-item ($strSrcFolder + "\" + $objSrcFile.Name )
$strDstFolder -force
}
}
# -----------------------------------------------------
# main
#backup the db and rename it with the actual day and move it to another location
$strSourceFolder = "D:\DB-Dumps\MSSQLCompressedBackup\BackupsTmp"
$strDestinationFolder = "\\Test-sqlb01\NVinity\RepositoryBackups_Test-EntwDB01"
$FSO = New-Object -COM Scripting.FileSystemObject
$objSourceFolder = $FSO.GetFolder($strSourceFolder)
$objDestinationFolder = $FSO.GetFolder($strDestinationFolder)
#backing up the db
invoke-expression -command "D:\DB-Dumps\MSSQLCompressedBackup\msbp.exe
backup `"db(database=NV_REP_ENTWICKLUNG)`"
`"zip64(level=3;filename=NV_REP_ENTWICKLUNG.bak)`"
`"local(path=d:\db-Dumps\MSSQLCompressedBackup\BackupsTmp\NV_REP_ENTWICKLUNG.bak.zip)`"
>> d:\db-Dumps\MSSQLCompressedBackup\BackupsTmp\NV_REP_ENTW_BACKUP_LOG.txt
"
#after running the msbp.exe, i backup the logfile and dbbackupfile to
another place in the intranet
BackupFolder $objSourceFolder $objDestinationFolder
best regards!
Otis
|