Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Backup and 7zip powershell script

$
0
0

I have a script that creates several backup files and is supposed to zip them up afterward.

This is the script:

Text
Import-Module "sqlps" -DisableNameChecking Invoke-Sqlcmd -Query "USE ASPNETDB; SELECT DATABASELOCATION, SITEID FROM FIREBIRDCONNECTIONS;" -ServerInstance "DV-SQLSTAG01\EXPRESS2014" | Export-CSV -Path "C:\Scripts\strings.csv" C: CD C:\Scripts $fbConn = Import-Csv -Path .\strings.csv ForEach ($site in $fbConn) { $cString = $site.DATABASELOCATION $siteid = $site.SITEID $backupDir = "D:\DBBackups" $backupFile = "Cpib_$siteid.bak" $gbak = ".\gbak.exe" $gbakArgs = "-b -g -user sysdba -password masterkey $cString $backupDir\$backupFile" $7zip = ".\7za.exe" $7zArgs = "a -v1g -r -y -t7z -mx=3 $backupDir\CPIB_$siteid@$(get-date -f yyyyMMdd).7za $backupDir\$backupFile" Start-Process $gbak $gbakArgs Start-Process $7zip $7zArgs } 

Now,...


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>