I use this script as windows schedule task on Database server to compress the backup file to 7z.But it also creates 7z file on C root and when i check the file it shows data of whole C drive.it start creating 7z for C drive.file creates without any name that is *.7z and i also checked 7zip temp folder set to "current" so temp files are created in current folder. what can be cause of creation of this 7z file?
Hello,I used the same code to zip my bak file , when the file small like 3MB ,it worked 200KB.But when the file big like 1.9GB, it does not worked 1.88GB.What's the problem? Or 7z is so ?
Good solution. My only issue is that you assume that 7-Zip is installed in $env:ProgramFiles. The actual install location can quite easily be obtained by: $path = "HKLM:\Software \7-Zip","HKLM:\ Software\Wow643 2Node\7-Zip"|%{ if (Test-Path $_) { gp $_ } }|Select -First 1 -ExpandProperty Path This will return firstly the 64bit path (if there is one) or the 32bit path if there is one. Or $null if none. Thanks, Chris.
The script works fine but i have one issue. I used to take daily backup if there any way that we can skip the zip process if the file already exists. i.e. on weekends i dont maually move the .bak files so it will zip the backup of saturday and sunday both can we put any condition where if .7z file exists it wil not zip them.
Hi Rakesh i will try to do that and i think that may be a little bit tricky to do. thanks aman
You could just create each archive with a Unique identifier using the below: $JobGuid = [GUID]::NewGUID() and then use $jobguid in the naming convention for your compression jobs.
Is it possible to change this so it adds each files to the same archive? I also tried adding sz a -t7z "$directory\$zipfile" "$directory\$na me" move-item $directory\*.7z $bkpfldr\.Name and cannot get it to procees the move-item portion..it will complete the for loop and then end. Any ideas? Many Thanks, this is a very simple and helpful solution for creating .7z archives.
hi ACLOCKEDTIGERSITUP can u please explain a little bit more. the question is quite unclear to me:( Sorry ... thanks aman