Archival Notice
This guide was consolidated from historical automation records managing distributed access log collection across early campus proxy servers and Web application modules (Tomcat 5). Adapt loop parameters and storage directories when managing modern container logging pipelines.
Aggregating raw user access logs and application state files across dozens of distributed server endpoints (such as regional proxy servers in east-dc1 or west-dc1) requires resilient scripting pipelines. Relying on manual file transfer connections across independent terminal sessions creates severe operational latency.
In this practical operations guide, I explore how to write automated Bash loops for remote SCP log retrieval, configure secure Log Analyzer SSH authorized keys, prompt for interactive log purge selections, and back up enterprise Web application container modules.
Part 1: Automated Multi-Node SCP Extraction Script (transfer_script.sh)
To fetch daily proxy access logs from distributed proxy server nodes into a centralized log analysis archive without manual intervention, run the custom automation script transfer_script.sh.
Deploy the script in /usr/local/bin/transfer_script.sh:
#!/bin/bash
# /usr/local/bin/transfer_script.sh
# Multi-node automated proxy log SCP collection engine
echo -n "Provide absolute destination folder directory path for transfer ingestion: "
read LOGFOLDER
mkdir -p "$LOGFOLDER"
echo "Ingesting remote logging structures into: $LOGFOLDER"
# Remote SCP extraction array
scp root@10.11.3.12:/backup/zub12access.log "$LOGFOLDER/"
scp root@10.11.3.13:/backup/kha13access.log "$LOGFOLDER/"
scp root@10.11.3.14:/backup/qas14access.log "$LOGFOLDER/"
scp root@10.11.3.15:/backup/dha15access.log "$LOGFOLDER/"
scp root@10.11.3.16:/backup/new16access.log "$LOGFOLDER/"
scp root@10.11.3.18:/backup/iqb18access.log "$LOGFOLDER/"
scp root@10.11.3.20:/backup/sir20access.log "$LOGFOLDER/"
scp root@10.11.3.22:/backup/lia22access.log "$LOGFOLDER/"
scp root@10.11.3.24:/backup/qua24access.log "$LOGFOLDER/"
scp root@10.11.3.26:/backup/zoh26access.log "$LOGFOLDER/"
scp root@10.11.3.27:/backup/aye27access.log "$LOGFOLDER/"
scp root@10.11.3.28:/backup/mum28access.log "$LOGFOLDER/"
scp root@10.11.3.31:/backup/ome31access.log "$LOGFOLDER/"
echo "Daily remote log collection completed perfectly."
Part 2: Interactive Remote Storage Clearing Scripts
Once raw access logs are verified in central log analysis archives, zero out the original server spools across remote proxy nodes to maintain available disk space.
Deploy the custom management loop script /usr/local/bin/deptlogtransfer.sh:
#!/bin/bash
# /usr/local/bin/deptlogtransfer.sh
# Remote interactive file clearing management interface
DELETE_FUNC () {
read -n 1 -p "Do you wish to purge origin log file $2 on remote host $1? (y/n): " CHOICE
echo ""
if [ "$CHOICE" = "y" ] || [ "$CHOICE" = "Y" ]; then
echo "Executing remote truncation on log file $2..."
ssh -o "StrictHostKeyChecking=no" "root@$1" "> /backup/$2"
echo "Remote file truncated successfully."
elif [ "$CHOICE" = "n" ] || [ "$CHOICE" = "N" ]; then
echo "Bypassing origin deletion for $2. File unmodified."
else
echo "Invalid choice parameters. Re-executing prompt..."
DELETE_FUNC "$1" "$2"
fi
}
# Invoking interactive remote truncation block
DELETE_FUNC "10.11.2.9" "primary_access.log"
Part 3: Locking Down Log Analyzer SSH Key Logins
To enable automated background collection engines without storing plaintext administrative credentials (such as RandomPassword) in cleartext scripts, lock down public key identities in /root/.ssh/authorized_keys.
mkdir -p /root/.ssh
chmod 700 /root/.ssh
vi /root/.ssh/authorized_keys
Append explicit trusted public key identities to the remote host authentication file:
# Log Analyzer Core Automation Authentication Identifiers
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6rPBXkerl55YEngoAvDC20vxD9ZvbnV/p5rkZtwtJf/lYtC7dG6FYcuh5ju5M2L8rIwCuN9WHNnt6WEQbzDcLOAIOtPZ+Ed1c1byk0/fq9Yp1YL5ODLCKbKw/E5CZJQZMmudcgOVOaS1JB1OlP7+ThJ6Gipoz6PzDg/YSRQikU8AMqdTjXSfOH1Ovhsbk1l4VwlTRtBm3GdKbvT4cTc+7VPjW4NR+UD8avVNq8u/x2gg+hV0OIkmnO4Du9iDaqZIgi3e1Pe4uTQPkC8Asqh9ktj042H4aac4zvZ6wJ21s7eN97PPgCc0Xxebjf7k/z5SUsbW4y+ldQpoC+xNtReVnw== root@loganalyser.induslevel.com
# Secure SSH profile permissions
chmod 600 /root/.ssh/authorized_keys
Part 4: Backing Up Core Apache Tomcat Web Modules
When performing maintenance across web application portals running inside enterprise containers (such as legacy Tomcat Webapps), clone active storage directories before running deployment changes.
# Navigate to web application packaging boundaries
cd /var/lib/tomcat5/webapps/ROOT/WEB-INF/packages/modules/
# Create application bundle snapshots
tar -cvzf /backup/tomcat_modules_snapshot.tar.gz .
Securely duplicate specific exported system module definitions across fallback operational paths:
# Verify base production module archives
cp -r /var/lib/tomcat5/webapps/ROOT/export/system/modules/com.enterprise.portal /backup/safe_export/
Gathering Complete
Your server management scripts are successfully ingesting remote application telemetry and establishing secure, zero-trust backup routines!
References
- OpenSSH Secure Public Key Management Protocol Manual
- Apache Tomcat Web Application Deployment direct specifications