0

We run S3 sync commands in a SQL Job which syncs a local directory to an S3 bucket. At times, we'll get a sync "error" with an error code of 1, or sometimes 2. The documentation lists what each code means; error code 1 provides less details and leaves more questions remaining about the problem. It simply states "One or more Amazon S3 transfer operations failed. Limited to S3 commands."

When I run a sync command in a PowerShell script, and encounter an error (i.e. a synced document being open), the window displays an error message and which specific file that is causing a problem.

How can I capture those details in my SQL job?

Jeff King
  • 17
  • 4
  • Looking at this post again after a couple of months and I see why it didn't garner many responses - It needs focus. The real question at hand is in regards to error code 1: What is the likely problem in those cases? – Jeff King Jul 08 '22 at 18:57
  • For anyone following along, I've discovered from this SO post https://stackoverflow.com/a/35076194/16577485 that I can react to error code 1 and route the output to a text file, possibly then learning which file(s) failed. Will post back my results. – Jeff King Jul 08 '22 at 20:10

1 Answers1

0

I have solved this problem...

Using a PowerShell script, in the AWS s3 sync command we output the results to a text file:

aws s3 sync c:\source\dir s3://target/dir/ > F:\Source\s3Inventory\SyncOutput.txt

Then read the text file contents into a string variable:

$S3Output = Get-Content -Path C:\Source\s3Inventory\SyncOutput.txt -Raw

If the $LASTEXITCODE from the sync command does not equal 0 (indicating an error), then we send an email with the results:

if ($LASTEXITCODE -ne 0)
    {   
        #Send email containing the value of string variable $S3Output        
    }

This has been placed into production and we were finally able to determine which file/object was failing.

One could certainly attach the text file to the email, rather than reading the contents into a string.

Hope this helps others!

Jeff King
  • 17
  • 4