Getting data from an S3 bucket
Connecting to an S3 bucket
Section titled “Connecting to an S3 bucket”To get data from an S3 bucket, you need to execute connect get s3
with following mandatory parameters:
--bucket
then the S3 bucket name--region
then the region where the bucket is located
Depending on the type of authentication you need to either use --access-key
and --secret-access-key
for key based authentication
or use the IAM Role Assigned to the Instance (if the server is running on AWS).
To use the Access Key and Secret Access Key authentication you need to provide:
--access-key
then the Access Key--secret-access-key
then the Secret Access Key
You can use aws configure
.
This command prompts you to enter the Access Key ID and Secret Access Key, which are then stored in your AWS CLI configuration file ~/.aws/credentials
.
Then you can omit providing the credentials as they will be obtained from the configuration.
If your instance is running in AWS the temporary credentials will be automatically retrieved from the instance metadata (unless you have overridden it with aws configure). You don’t have to specify the credentials then.
To connect to an S3-compatible service like Minio you need to provide the URL using:
--custom-url
and then the S3 instance URL
Getting single file from an S3 bucket
Section titled “Getting single file from an S3 bucket”To get a single file from an S3 bucket you should use
--file
followed by the file name to be downloaded
Following command will get file1.zip
file from an S3 bucket my-s3-bucket
bucket in eu-central-1
region using Access Key and Secret Access Key authentication.
$ connect get s3 --file file1.zip --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM42025/06/05 10:39:09 INFO Getting files from s3://my-s3-bucket/[file1.zip] 10.00 MiB / 10.00 MiB done
Getting multiple files from an S3 bucket
Section titled “Getting multiple files from an S3 bucket”If you’d like to get multiple files from an S3 bucket you need to specify either file mask or file regular expression for the files.
--file-mask
a file mask--file-regex
regular expression
This will download all files that match a certain mask or pattern. You can also provide an optional source folder that contains the files to be downloaded:
-s, --src-folder
folder containing the files to download
If you don’t provide the source folder files will be downloaded from “root folder” of the S3 bucket.
Following command will get all .zip
files from data
folder of S3 bucket my-s3-bucket
in eu-central-1
region using Access Key and Secret Access Key authentication.
$ connect get s3 --file-mask "*.zip" -s data --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM42025/06/05 10:40:44 INFO Getting files from s3://my-s3-bucket/data/[file1.zip] 10.00 MiB / 10.00 MiB done[file2.zip] 10.00 MiB / 10.00 MiB done[file3.zip] 10.00 MiB / 10.00 MiB done
You can also provide an optional destination folder where the files will be downloaded to:
-d, --dst-folder
target folder where to download files
If you don’t provide the destination folder files will be downloaded to the current folder.
In below example all .zip
files from data
folder of S3 bucket my-s3-bucket
in eu-central-1
region will be downloaded to local
folder using Access Key and Secret Access Key authentication.
$ connect get s3 --file-mask "*.zip" -s data -d local --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM42025/06/05 10:41:58 INFO Getting files from s3://my-s3-bucket/data/[file1.zip] 10.00 MiB / 10.00 MiB done[file2.zip] 10.00 MiB / 10.00 MiB done[file3.zip] 10.00 MiB / 10.00 MiB done
Getting files from an S3 bucket in batch mode
Section titled “Getting files from an S3 bucket in batch mode”When using the application in batch or non-interactive mode, such as in a script or scheduler, you should disable the progress bar by using
--batch
to get files in batch mode
Following command will get all .zip
files from the data
folder of S3 bucket my-s3-bucket
in eu-central-1
region and place them in the local
folder, using batch mode and Access Key and Secret Access Key authentication.
$ connect get s3 --file-mask "*.zip" -s data -d local --batch --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM42025/06/05 10:45:23 INFO Getting files from s3://my-s3-bucket/data/2025/06/05 10:45:23 INFO Files to get: count=32025/06/05 10:45:23 INFO Transferring file=data/file1.zip targetFolder=local2025/06/05 10:45:23 INFO File transferred successfully bytesTransferred=10485760 duration=157ms transferRate=63.53MB/s file=data/file1.zip targetFolder=local2025/06/05 10:45:23 INFO Transferring file=data/file2.zip targetFolder=local2025/06/05 10:45:23 INFO File transferred successfully bytesTransferred=10485760 duration=102ms transferRate=97.90MB/s file=data/file2.zip targetFolder=local2025/06/05 10:45:23 INFO Transferring file=data/file3.zip targetFolder=local2025/06/05 10:45:23 INFO File transferred successfully bytesTransferred=10485760 duration=99ms transferRate=100.83MB/s file=data/file3.zip targetFolder=local
Getting files from an S3 bucket using scheduler
Section titled “Getting files from an S3 bucket using scheduler”When running the application from a scheduler, it’s recommended to ensure only one instance operates on a specific folder. It’s possible to configure the application to create a flag file at startup and delete it upon completion. If another instance tries to start while one is already running, it will detect the flag file and exit. This approach ensures that only one instance of the application runs at any given time. To do that use
--flag
path to the flag file
Following command will get all .zip
files from the data
folder of S3 bucket my-s3-bucket
in eu-central-1
region and place them in the local
folder using /tmp/flag1
as a flag file and Access Key and Secret Access Key authentication.
Mind that we are using batch mode as it’s required for the application to run correctly from script or scheduler.
$ connect get s3 --flag /tmp/flag1 --batch --file-mask "*.zip" -s data -d local --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM42025/06/05 10:49:40 INFO Using flag file: /tmp/flag12025/06/05 10:49:40 INFO Getting files from s3://my-s3-bucket/data/2025/06/05 10:49:40 INFO Files to get: count=32025/06/05 10:49:40 INFO Transferring file=data/file1.zip targetFolder=local2025/06/05 10:49:40 INFO File transferred successfully bytesTransferred=10485760 duration=138ms transferRate=72.01MB/s file=data/file1.zip targetFolder=local2025/06/05 10:49:40 INFO Transferring file=data/file2.zip targetFolder=local2025/06/05 10:49:40 INFO File transferred successfully bytesTransferred=10485760 duration=117ms transferRate=85.34MB/s file=data/file2.zip targetFolder=local2025/06/05 10:49:40 INFO Transferring file=data/file3.zip targetFolder=local2025/06/05 10:49:40 INFO File transferred successfully bytesTransferred=10485760 duration=98ms transferRate=101.84MB/s file=data/file3.zip targetFolder=local2025/06/05 10:49:40 INFO Removing flag file: /tmp/flag1
Getting files from an S3 bucket in parallel
Section titled “Getting files from an S3 bucket in parallel”To speed up file download you can fetch files simultaneously. Application will then get files using multiple sessions. To specify number of concurrent S3 sessions use:
--parallel
number of S3 sessions
Following command will get all .zip
files from data
folder of S3 bucket my-s3-bucket
in eu-central-1
region using 3
parallel sessions.
$ connect get s3 --file-mask "*.zip" -s data --batch --parallel 3 --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key PHQlr4HsdFijIRCxMqFXDRS8lSh+WBABqFjIQWM42025/06/05 11:29:35 INFO Getting files from s3://my-s3-bucket/data/2025/06/05 11:29:35 INFO Files to get: count=32025/06/05 11:29:35 INFO Transferring file=data/file3.zip targetFolder=2025/06/05 11:29:35 INFO Transferring file=data/file2.zip targetFolder=2025/06/05 11:29:35 INFO Transferring file=data/file1.zip targetFolder=2025/06/05 11:29:35 INFO File transferred successfully bytesTransferred=10485760 duration=194ms transferRate=51.48MB/s file=data/file3.zip targetFolder=2025/06/05 11:29:35 INFO File transferred successfully bytesTransferred=10485760 duration=256ms transferRate=39.03MB/s file=data/file1.zip targetFolder=2025/06/05 11:29:35 INFO File transferred successfully bytesTransferred=10485760 duration=278ms transferRate=35.86MB/s file=data/file2.zip targetFolder=
Getting files from an S3 bucket in sequence
Section titled “Getting files from an S3 bucket in sequence”If you don’t specify the --parallel
option then files will be downloaded using single S3 session in the same order as they showed up on S3 bucket (oldest files first).
Action after file is downloaded from an S3 bucket
Section titled “Action after file is downloaded from an S3 bucket”After file is successfully downloaded to local system it’s possible to remove it from source or move it to a different folder at the source system.
--delete
delete a file after it’s downloaded--move-folder
target folder to move the file after it’s downloaded
Following command will get all .zip
files from data
folder of S3 bucket my-s3-bucket
in eu-central-1
region using 3
parallel sessions and store them in local
folder. Then files will be moved to archive
folder at in the S3 bucket.
$ connect get s3 --file-mask "*.zip" -s data -d local --batch --parallel 3 --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key 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 --move-folder archive2025/06/05 11:31:11 INFO Getting files from s3://my-s3-bucket/data/2025/06/05 11:31:11 INFO Files to get: count=32025/06/05 11:31:11 INFO Transferring file=data/file1.zip targetFolder=local2025/06/05 11:31:11 INFO File moved to folder folder=archive file=data/file1.zip2025/06/05 11:31:11 INFO File transferred successfully bytesTransferred=10485760 duration=169ms transferRate=58.86MB/s file=data/file1.zip targetFolder=local2025/06/05 11:31:11 INFO Transferring file=data/file2.zip targetFolder=local2025/06/05 11:31:11 INFO File moved to folder folder=archive file=data/file2.zip2025/06/05 11:31:11 INFO File transferred successfully bytesTransferred=10485760 duration=99ms transferRate=100.21MB/s file=data/file2.zip targetFolder=local2025/06/05 11:31:11 INFO Transferring file=data/file3.zip targetFolder=local2025/06/05 11:31:12 INFO File moved to folder folder=archive file=data/file3.zip2025/06/05 11:31:12 INFO File transferred successfully bytesTransferred=10485760 duration=94ms transferRate=105.49MB/s file=data/file3.zip targetFolder=local
Following command will get all .zip
files from data
folder of S3 bucket my-s3-bucket
in eu-central-1
region using 3
parallel sessions and then remove the files from the S3 bucket.
$ connect get s3 --file-mask "*.zip" -s data --batch --parallel 3 --bucket my-s3-bucket --region eu-central-1 --access-key AKIA4YINCR26KRN42IDA --secret-access-key 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 --delete2025/06/05 11:33:41 INFO Getting files from s3://my-s3-bucket/data/2025/06/05 11:33:41 INFO Files to get: count=32025/06/05 11:33:41 INFO Transferring file=data/file2.zip targetFolder=2025/06/05 11:33:41 INFO File deleted file=data/file2.zip2025/06/05 11:33:41 INFO File transferred successfully bytesTransferred=10485760 duration=116ms transferRate=86.06MB/s file=data/file2.zip targetFolder=2025/06/05 11:33:41 INFO Transferring file=data/file3.zip targetFolder=2025/06/05 11:33:41 INFO File deleted file=data/file3.zip2025/06/05 11:33:41 INFO File transferred successfully bytesTransferred=10485760 duration=96ms transferRate=104.14MB/s file=data/file3.zip targetFolder=2025/06/05 11:33:41 INFO Transferring file=data/file1.zip targetFolder=2025/06/05 11:33:41 INFO File deleted file=data/file1.zip2025/06/05 11:33:41 INFO File transferred successfully bytesTransferred=10485760 duration=98ms transferRate=101.88MB/s file=data/file1.zip targetFolder=
All S3 Get Options
Section titled “All S3 Get Options”Usage: connect get s3 [command] [flags]
Flags: --access-key string S3 access key --bucket string S3 bucket --custom-url string S3 custom URL --region string S3 region --secret-access-key string S3 secret access key
Global Flags: --batch No progress bars --delete Try to delete files after successful get -d, --dst-folder string Destination folder for retrieved files --file string File name to be get --file-mask string File mask to filter files --file-regex string File regex to filter files --flag string Flag file name --from-mail string From mail used to send notifications (only in batch mode) --godebug Turns on debug mode --help Prints help for the command --log-format string Log output format: text|json (default "text") --mail-format string Mail format [text|html] (only in batch mode) (default "plain") --move-folder string Folder to move files after successful get --no-color Do not use colors in logs --parallel uint Number of sessions used to get files (default 1) --quiet Makes no output -s, --src-folder string Folder to look for files --to-mail-failure strings Email list to send failure notification (only in batch mode) --to-mail-success strings Email list to send success notification (only in batch mode)
Errors
Section titled “Errors”Please check here for information on the possible errors.