SSHFileToCbs - File Transfer Application
A modern Python implementation of a file transfer application between local and remote servers using SSH/SFTP or FTP.
Features
- Support for both SSH/SFTP and FTP protocols
- Robust logging with rotation
- System monitoring for performance and resource usage
- Error handling and recovery
- Configurable file paths and patterns
- Clean code architecture following modern Python practices
Requirements
- Python 3.6+
- Dependencies listed in requirements.txt
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Configuration
Create or edit the config/config.ini
file with your server details and file paths:
[server]
REMOTE_HOST=your_host
REMOTE_USER=your_username
REMOTE_PASS=your_password
REMOTE_PORT=22
[app]
SLEEP_TIME_MINS=30
TRANSFER_PROTOCOL=SSH
[paths]
LOCAL_FOLDER_PATH=/path/to/local/files/
ARCHIVE_FOLDER_PATH=/path/to/archive/
LOCAL_REPORT_PATH=/path/to/report/files/
LOCAL_FAILED_PATH=/path/to/failed/files/
[remote_paths]
REMOTE_REPORT_PATTERN=BLK_*
REMOTE_INPUT_FILE_PATH=path/to/input/
REMOTE_OUTPUT_FILE_PATH=path/to/output/
REMOTE_FAILURE_FILE_PATH=path/to/failure/
Usage
Run the application with:
python main.py
Command Line Options
--config
: Path to configuration file (default: config/config.ini)--log-level
: Set logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
How It Works
The application:
- Sends local files to the remote server
- Archives sent files locally
- Fetches report files from the remote server
- Fetches failed files from the remote server
- Sleeps for a configured period
- Repeats the cycle
Architecture
protocols/
: Protocol interfaces and implementations (SSH, FTP)services/
: Core services for file sending and fetchingfile_operations/
: Local file management utilitiesutils/
: Logging, configuration, and monitoring utilitiesapp.py
: Main application classmain.py
: Entry point and command-line interface
Description
Languages
Python
100%