I have found many examples how to zip ziles, but is there native to P/S how to create multiple zip files based upon a parm to split them based upon given filesize?
I have a large backup file .bak that I would like to split into x files as based upon a parm of filesz. If I set filesz to 100mb it creates x zip files of 100mb based upon what size of the .bak file.
Thanks.
March 17, 2022 at 3:48 pm
Try this. Splits files, then zips each one.
$from = "C:\temp\bigfile.exe"
$rootName = "C:\temp\bigfile"
$ext = "chunk"
$upperBound = 500KB
$fromFile = [io.file]::OpenRead($from)
$buff = new-object byte[] $upperBound
$count = $idx = 0
try {
do {
"Reading $upperBound"
$count = $fromFile.Read($buff, 0, $buff.Length)
if ($count -gt 0) {
$to = "{0}.{1}.{2}" -f ($rootName, $idx, $ext)
$toFile = [io.file]::OpenWrite($to)
try {
"Writing $count to $to"
$tofile.Write($buff, 0, $count)
} finally {
$tofile.Close()
compress-archive $to "$to.zip"
}
}
$idx ++
} while ($count -gt 0)
}
finally {
$fromFile.Close()
}
March 17, 2022 at 3:51 pm
I don't believe windows will do split zip files natively so you would need to download some other program to do it. 7-zip does have a command line so that might work.
March 17, 2022 at 4:53 pm
Cool.
That worked perfect to do split is there away then to using the chunk file to recreate the original file I zipped.
March 18, 2022 at 10:45 am
I want to get rid of the BIG file I'm trying to ZIP but need to make sure I can recreate from the multiple Chunk files created..
Thx.
Try this. Please mark as answered if this does the trick.
ls "c:\temp\bigfile*chunk*.zip" | Expand-Archive -force -destinationpath c:\temp
cmd /c copy /b "c:\temp\bigfile*chunk" "c:\temp\bigfile.exe"
March 18, 2022 at 4:59 pm
Perfect Thanks!!!!
March 19, 2022 at 6:07 pm
I have found many examples how to zip ziles, but is there native to P/S how to create multiple zip files based upon a parm to split them based upon given filesize?
I have a large backup file .bak that I would like to split into x files as based upon a parm of filesz. If I set filesz to 100mb it creates x zip files of 100mb based upon what size of the .bak file.
Thanks.
What is it that you're actually trying to do... email a large .bak to someone or something? If that's true, why not just copy it to somewhere where other people can simply download it. GitHub, for example.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 20, 2022 at 12:33 pm
I have found many examples how to zip ziles, but is there native to P/S how to create multiple zip files based upon a parm to split them based upon given filesize?
I have a large backup file .bak that I would like to split into x files as based upon a parm of filesz. If I set filesz to 100mb it creates x zip files of 100mb based upon what size of the .bak file.
Thanks.
Quick questions, what version and edition of SQL Server are you using? Is this a backup file? If so, why don't you simply use backup compression (gzip algo) and multiple destination files, produces almost the same result?
😎
March 21, 2022 at 2:14 am
Bruin wrote:I have found many examples how to zip ziles, but is there native to P/S how to create multiple zip files based upon a parm to split them based upon given filesize?
I have a large backup file .bak that I would like to split into x files as based upon a parm of filesz. If I set filesz to 100mb it creates x zip files of 100mb based upon what size of the .bak file.
Thanks.
Quick questions, what version and edition of SQL Server are you using? Is this a backup file? If so, why don't you simply use backup compression (gzip algo) and multiple destination files, produces almost the same result?
😎
I was thinking in a similar fashion until I saw the 100MB limit per file. That smacks of someone trying to send a database via multiple emails. I don't have what are consider to be really big databases but I do have tables with NCI's that would take 650 of those size files.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 21, 2022 at 11:41 am
It was to transfer files across network to backup storage location. I was weighing impact of doing the compression in the SQL backup versus a script..
Thx.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply