Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, in the meantime I cobbled together another solution. Maybe it will be of use to someone..</p> <p>[Run.cmd] --May need to change powershell path</p> <pre><code>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nologo -noninteractive -command "C:\Scripts\RunBackup.ps1" </code></pre> <p>[RunBackup.ps1] --Out-File not having the desired effect, maybe someone can figure out why?</p> <pre><code>C:\Scripts\SqlBackup.ps1 | Out-File "C:\Scripts\log.txt" C:\Scripts\SVNBackup.ps1 | Out-File "C:\Scripts\log.txt" C:\Scripts\Zip.ps1 | Out-File "C:\Scripts\log.txt" </code></pre> <p>[SqlBackup.ps1] --You may need to modify which SMO assemblies are loaded, depending on your version of SQL server. Don't forget to set $instance and $bkdir.</p> <pre><code>#http://www.mssqltips.com/tip.asp?tip=1862&amp;home $instance = ".\SQLEXPRESS" [System.Reflection.Assembly]::LoadFrom("C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.SMO.dll") | out-null [System.Reflection.Assembly]::LoadFrom("C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.SMOExtended.dll") | out-null $s = new-object ("Microsoft.SqlServer.Management.Smo.Server") $instance $bkdir = "c:\Backups" #We define the folder path as a variable $dbs = $s.Databases foreach ($db in $dbs) { if($db.Name -ne "tempdb") #We don't want to backup the tempdb database { $dbname = $db.Name $dt = get-date -format yyyyMMddHHmm #We use this to create a file name based on the timestamp $dbBackup = new-object ("Microsoft.SqlServer.Management.Smo.Backup") $dbBackup.Action = "Database" $dbBackup.Database = $dbname $dbBackup.Devices.AddDevice($bkdir + "\" + $dbname + "_db_" + $dt + ".bak", "File") $dbBackup.SqlBackup($s) } if($db.RecoveryModel -ne 3) #Don't issue Log backups for DBs with RecoveryModel=3 or SIMPLE { $dbname = $db.Name $dt = get-date -format yyyyMMddHHmm #Create a file name based on the timestamp $dbBackup = new-object ("Microsoft.SqlServer.Management.Smo.Backup") $dbBackup.Action = "Log" $dbBackup.Database = $dbname $dbBackup.Devices.AddDevice($bkdir + "\" + $dbname + "_log_" + $dt + ".trn", "File") $dbBackup.SqlBackup($s) } } </code></pre> <p>[SVNBackup.ps1] --Modify repo and backup paths</p> <pre><code>#set alias to svnadmin exe set-alias svnadmin "C:\Program Files (x86)\CollabNet Subversion Server\svnadmin.exe" #create dump cmd.exe /c svnadmin dump "C:\Repo" `&gt; "C:\Backups\svn.dmp" #remove alias remove-item alias:svnadmin </code></pre> <p>[Zip.ps1] --Need to have 7zip installed, modify 7z.exe path if necessary</p> <pre><code>#set alias to command line version of 7zip set-alias sevenz "c:\program files\7-zip\7z.exe" #Backups location cd 'C:\Backups' #rar the contents of the directory $dt = get-date -format yyyyMMddHHmm #We use this to create a file name based on the timestamp $outputFileName = "SQLSVNBackup$dt.7z" $exclude1 = "-x!*.rar" $exclude2 = "-x!*.7z" sevenz a -t7z "$outputFileName" *.* "$exclude1" "$exclude2" #find all .bak files in the immediate directory dir '*.bak' | foreach-object{ #remove the bak file remove-item $_.name } #find all .dmp files in the immediate directory dir '*.dmp' | foreach-object{ #remove the dmp file remove-item $_.name } #find all .trn files in the immediate directory dir '*.trn' | foreach-object{ #remove the trn file remove-item $_.name } #remove 7zip alias remove-item alias:sevenz </code></pre> <p>I used <a href="http://www.goodsync.com" rel="nofollow noreferrer">GoodSync</a> to backup to WebDAV and scheduled two tasks to run the .cmd file and then sync/backup offsite.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload