Problem with 7zip unzip using exec master..xp_cmdshell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JinxT
    New Member
    • Apr 2008
    • 9

    #1

    Problem with 7zip unzip using exec master..xp_cmdshell

    Hi,

    I am trying to implement custom log shipping but only have Standard Edition to am unable to use compressed backups..so have resorted to a customised version. As our transaction log files can reach several gb I need them zipped.

    I have managed to zip a file using xp_cmdshell as follows:

    Code:
    exec master..xp_cmdshell 'C:\Progra~1\7-Zip\7z.exe a -t7z "D:\Microsoft SQL Server\MSSQL\Backup\archive_data.7z" "D:\Microsoft SQL Server\MSSQL\Backup\data.bak"'
    But I cannot get the syntax correct for unzipping the file.
    I've tried using similar code to above by replacing the 'a' with an 'e' or 'x' but get the following error:

    Cannot use absolute pathnames for this command.

    I've tried different pathnames but all generate similar errors, or simply do not recognise the path at all.

    Can any one point me in the right direction?

    Thanks,

    Jinx.
  • tonk
    New Member
    • Apr 2010
    • 1

    #2
    I've done a quick test and the following seems to work for me...

    exec master..xp_cmds hell 'C:\Progra~1\7-Zip\7z.exe e "D:\Microso ft SQL Server\MSSQL\Ba ckup\archive_da ta.7z" -o"D:\Microso ft SQL Server\MSSQL\Ba ckup\"'

    The ‘e’ option tells 7Zip to do the extraction, the ‘–o’ option tells 7Zip where to put the extracted files, putting in an absolute path in seems to work for me, lemme know if you have any problems ^^

    Comment

    • JinxT
      New Member
      • Apr 2008
      • 9

      #3
      Thanks Tonk, including the '-o' in the "" solved it for me!

      Comment

      Working...