# Deployment Guide This guide explains how to deploy the SSHFileToCbs Python application in a production environment. ## Prerequisites - Python 3.6 or higher - pip for package installation - Access to a Linux server (Ubuntu/Debian or CentOS/RHEL instructions provided) ## Installation Steps ### 1. Clone or Copy the Application Clone the repository or copy the application files to the deployment server: ```bash # Optional: create a directory for the application mkdir -p /opt/ssh-file-to-cbs # Copy application files cp -R /path/to/SSHFileToCbs_PYTHON/* /opt/ssh-file-to-cbs/ cd /opt/ssh-file-to-cbs ``` ### 2. Install Required Packages Install the required Python packages: ```bash pip3 install -r requirements.txt # Or install as a package pip3 install -e . ``` ### 3. Configure the Application Edit the configuration file to match your environment: ```bash cp config/config.ini config/config.production.ini # Edit the configuration file nano config/config.production.ini ``` Update the following settings: - Server connection details - Local and remote file paths - Transfer protocol and other application settings ### 4. Set Up as a System Service For reliable operation, set up the application as a system service: #### For systemd-based systems (Ubuntu, Debian, CentOS 7+, RHEL 7+): ```bash # Copy the service file sudo cp ssh-file-to-cbs.service /etc/systemd/system/ # Edit the service file if necessary to update paths sudo nano /etc/systemd/system/ssh-file-to-cbs.service # Reload systemd to recognize the new service sudo systemctl daemon-reload # Enable the service to start on boot sudo systemctl enable ssh-file-to-cbs.service # Start the service sudo systemctl start ssh-file-to-cbs.service # Check the status sudo systemctl status ssh-file-to-cbs.service ``` ### 5. Set Up Log Rotation Although the application has built-in log rotation, it's a good practice to set up system-level log rotation as well: ```bash sudo nano /etc/logrotate.d/ssh-file-to-cbs ``` Add the following content: ``` /opt/ssh-file-to-cbs/logs/*.log { daily missingok rotate 14 compress delaycompress notifempty create 0640 user group sharedscripts postrotate systemctl restart ssh-file-to-cbs.service >/dev/null 2>&1 || true endscript } ``` Replace `user` and `group` with the appropriate values for your system. ### 6. Verify Installation Check if the application is running correctly: ```bash # Check service status sudo systemctl status ssh-file-to-cbs.service # Check logs tail -f /opt/ssh-file-to-cbs/logs/SSHFileToCbs_YYYYMMDD.log ``` ## Troubleshooting ### Service Won't Start Check the logs for errors: ```bash sudo journalctl -u ssh-file-to-cbs.service -n 50 ``` ### Connection Issues Verify network connectivity and credentials: ```bash # Test SSH connectivity ssh -p @ # Test network connectivity ping telnet ``` ### Permission Issues Ensure the application has proper permissions to read/write files: ```bash # Check directory permissions ls -la /path/to/local/files/ ls -la /path/to/archive/ # Change ownership if needed sudo chown -R user:group /path/to/directory/ ``` ## Monitoring The application has built-in monitoring, but you can also set up external monitoring: ### Check Application Logs ```bash tail -f /opt/ssh-file-to-cbs/logs/SSHFileToCbs_*.log ``` ### Set Up Monitoring Alerts Consider setting up monitoring with tools like Prometheus, Nagios, or a simple cron job that checks the logs for errors: ```bash # Example cron job to check logs for errors */10 * * * * grep -i "error" /opt/ssh-file-to-cbs/logs/SSHFileToCbs_$(date +\%Y\%m\%d).log >/dev/null && echo "Errors found in SSH File to CBS logs" | mail -s "SSH File to CBS Error" admin@example.com ```