0

I am trying to automate the upload of files to Glacier using Cloudberry Explorer's PowerShell snapin but cannot seem to copy files to my preferred destination. For some reason, the source directory structure is mirrored in the Glacier vault. For example, the following occurs:

  • source path: c:\folder1\subfolder1\yyyyMMdd.tar.bz2
  • actual destination path: us-east-1/vaultName/c:\folder1\subfolder1\yyyyMMdd.tar.bz2
  • preferred destination path: us-east-1/vaultName/yyyyMMdd.tar.bz2

Any ideas on how to change this behavior?

Code:

#get name of oldest subfolder. subfolder names are based on date they were generated yyyyMMdd

$oldestFolder = Get-ChildItem C:\folder1\subfolder1 -directory -name | Sort-Object -descending | select -last 1
$dateToProcess = $oldestFolder

$srcFolder = "C:\folder1\subfolder1\"
$dstFolder = $srcFolder

# Compress directory before transmission

$block = [scriptblock]::Create("7z a -ttar $dstFolder$dateToProcess.tar $srcFolder$dateToProcess; 7z a -tbzip2 $dstFolder$dateToProcess.tar.bz2 $dstFolder$dateToProcess.tar; del $dstFolder$dateToProcess.tar")
& $block

add-pssnapin CloudBerryLab.Explorer.PSSnapIn

# Create connection

$conn = Get-CloudGlacierConnection -UseSSL -Key [Access key] -Secret [Secret Key]

# Set options

Set-CloudOption -GlacierChunkSizeMB 4
Set-CloudOption -GlacierParallelUpload 1

$vault = $conn | Select-CloudFolder -Path "us-east-1/vaultName"

$destination = $vault

# Select source folder

$src = Get-CloudFilesystemConnection | Select-CloudFolder $srcFolder

# Upload files to Glacier by filter

$src | Copy-CloudItem -Destination $destination -Filter "$dateToProcess.tar.bz2"
  • $dstFolder = $srcFolder I assume $dskFolder shoild be the root of the vault. – Antoine Jun 29 '17 at 15:11
  • @Antoine $dstFolder is the same as source. I am using $dstFolder as destination for the compression of the directory. $destination is the root of the vault. – MRodz Jun 30 '17 at 12:27
0

Instead of this piece of the script:

$block = [scriptblock]::Create("7z a -ttar $dstFolder$dateToProcess.tar $srcFolder$dateToProcess; 7z a -tbzip2 $dstFolder$dateToProcess.tar.bz2 $dstFolder$dateToProcess.tar; del $dstFolder$dateToProcess.tar")

There should be the following:

$block = [scriptblock]::Create("7z a -ttar $dstFolder$dateToProcess.tar $srcFolder$dateToProcess; 7z a -tbzip2 $dateToProcess.tar.bz2 $dstFolder$dateToProcess.tar; del $dateToProcess.tar") 

"c:\folder1\subfolder1" being added to your filename with the following command:
7z a -tbzip2 $dateToProcess.tar.bz2 $dstFolder$dateToProcess.tar

  • I tested the change; it doesn't work. In removing the path ($dstFolder) to the bz2 archive, 7zip outputs the following error: Open ERROR: Can not open the file as [bzip2] archive. ERRORS: Is not archive. System ERROR: Incorrect function. – MRodz Jul 9 '17 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.