Async SFTP uploader CLI with parallel uploads and retry logic
Project description
SFTP Uploader
A high-performance CLI tool for uploading folders to SFTP servers with async parallel uploads, automatic retries, and progress reporting.
Features
- 🚀 Async Parallel Uploads: Upload multiple files simultaneously for improved performance
- 🔄 Automatic Retry: Configurable retry logic with exponential backoff for failed uploads
- 📊 Progress Tracking: Real-time progress bar showing upload status
- 📈 Detailed Reporting: Summary statistics showing successful, failed, and skipped files
- 🔐 Flexible Authentication: Support for password and SSH key authentication
- 🌳 Recursive Upload: Maintain directory structure when uploading folders
- ⚙️ Environment Variables: Configure settings via environment variables
Installation
cd tools/upload-sftp
pip install -e .
Usage
Basic Usage
upload-sftp /path/to/local/folder /remote/folder \
--host sftp.example.com \
--username myuser \
--password mypassword
Using SSH Key Authentication
upload-sftp /path/to/local/folder /remote/folder \
--host sftp.example.com \
--username myuser \
--key-file ~/.ssh/id_rsa
Advanced Options
upload-sftp /path/to/local/folder /remote/folder \
--host sftp.example.com \
--port 2222 \
--username myuser \
--password mypassword \
--max-workers 20 \
--max-retries 5 \
--no-recursive
Using Environment Variables
Create a .env file or export environment variables:
export SFTP_HOST=sftp.example.com
export SFTP_PORT=22
export SFTP_USERNAME=myuser
export SFTP_PASSWORD=mypassword
# Or use key file:
# export SFTP_KEY_FILE=~/.ssh/id_rsa
Then run without specifying these options:
upload-sftp /path/to/local/folder /remote/folder
Command-Line Options
| Option | Short | Description | Default | Environment Variable |
|---|---|---|---|---|
--host |
-h |
SFTP server hostname | Required | SFTP_HOST |
--port |
-p |
SFTP server port | 22 | SFTP_PORT |
--username |
-u |
SFTP username | Required | SFTP_USERNAME |
--password |
SFTP password | None | SFTP_PASSWORD |
|
--key-file |
-k |
SSH private key file | None | SFTP_KEY_FILE |
--max-workers |
-w |
Max parallel uploads | 10 | - |
--max-retries |
-r |
Max retries per file | 3 | - |
--recursive |
Upload recursively | True | - | |
--no-recursive |
Don't upload recursively | - | - |
Example Output
Starting SFTP Upload
Local folder: /Users/john/documents
Remote folder: /backup/documents
SFTP host: sftp.example.com:22
Max parallel workers: 10
Max retries per file: 3
Uploading files... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Upload Summary
Total files found: 150
Successfully uploaded: 148
Failed: 2
Skipped: 0
Total time: 12.45 seconds
Failed Files:
• /Users/john/documents/large_file.zip: Connection timeout
• /Users/john/documents/locked.txt: Permission denied
Performance Tips
- Adjust Workers: Increase
--max-workersfor better performance on fast connections - Network Optimization: Use servers geographically closer to reduce latency
- Retry Configuration: Adjust
--max-retriesbased on network stability - File Size: Larger files benefit less from parallel uploads
Error Handling
The tool automatically retries failed uploads with exponential backoff:
- 1st retry: 1 second wait
- 2nd retry: 2 seconds wait
- 3rd retry: 4 seconds wait
- And so on...
Failed uploads are reported at the end with specific error messages.
Security Notes
⚠️ Important: The tool currently disables SSH host key verification for convenience. For production use, consider implementing proper host key verification.
Requirements
- Python 3.13+
- asyncssh
- typer
- rich
Development
# Install in development mode
pip install -e .
# Run directly
python -m upload_sftp.cli --help
License
Part of the LateralCare project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file upload_sftp-0.1.0.tar.gz.
File metadata
- Download URL: upload_sftp-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.28
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
972a3ac26376721e65f5c78580dbe5124d7d4d78bac18d709953199c97290b9d
|
|
| MD5 |
51bf11022fa446d35233092bcd950403
|
|
| BLAKE2b-256 |
b925f71ad200d7581c5fefbbaedf2b1181135d90d5b62c841bb89d25594c256f
|
File details
Details for the file upload_sftp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: upload_sftp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.28
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ffa5033ab6b2a8920eb0512e9db806875ef5a91121f16b7a4ef0ac591e907b4
|
|
| MD5 |
639b5b752f5b69a5dc5e7742a6285435
|
|
| BLAKE2b-256 |
be9f85de0603adbbfceea0232ce9320d00c6ac0bdb968bf9d22de16ef0b04307
|