Our corporate backup crap ware has failed me and I am rolling my own backup/archival script to be scheduled to run on a weekly basis.
What I have so far is:
$dst = "S:\VM-Bak"
$src = "D:\Work\Projects\CPS\MR4"
$fileName = "CPS-MR4.tar.gz"
$archive = $fileNam + "-" + (Get-Date -Format "yyyyMMdd")
$sigName = $fileName + ".sig"
$errorLog = (Join-Path -Path $dst -ChildPath ($fileName + ".err"))
Start-Process powershell -Verb runAs -WindowStyle Hidden
Get-ChildItem -Exclude *.vmem -Recurse -Path $src -ErrorAction SilentlyContinue `
| Write-Tar -OutputPath (Join-Path -Path $dst -ChildPath $archive) -EntryPathRoot`
$src | Write-GZip -Level 9 | Get-Hash | Format-Table -Property Path, Algorithm,`
HashString, @{Label ="Date"; Expression ={(Get-Date -Format "dd/MMM/yyyy")}} `
-AutoSize -ErrorAction SilentlyContinue | Out-File -FilePath (Join-Path -Path $dst `
-ChildPath $sigName) -Append
Now, by no stretch of the imagination can I be considered supremely well versed in powershell, but I can google and figure things out. Having said that the intent of this script is to grab my VM, skip over any vmem files (which always err out on not having access), collect the entire contents of the folder into a tar file then compress the output to a different drive. It does a lot of hard work and then after some time (its a 150GB VM) I have my stamped, tar-ed compressed VM.
The caveats. Trying to check the archive with winzip or 7zip, both programs claim that it is not an archive (I tried winzip out of frustration). I tried to open it as a tar archive, same thing. The exact error I get is:
Cannot open {path:\to\real file name} as archive
I can't figure out what's wrong. I read on some post that I should use -passthru on write-tar, but no such switch exists (this is PSCX 3.0.0)
Bonus points if you can also help me with the signature file so that it appends to a table and outputs the table from the follwing (not implemented in the above script)
Get-Hash | Format-Table -AutoSize -Property Path, Algorithm, Hashstring, `
@{Label="Date";Expression={(Get-Date -Format "dd/MMM/yyyy")}}