Added possibility to set remote base path to get logs from
@@ -14,14 +14,15 @@ if [ $# -lt 3 ] ; then
echo "[X] Error - need the remote system's filebeats hostname as 2nd parameter."
echo "[X] Error - need the username to connect with as 3rd parameter."
echo "[X] Optional - need the remote system's ssh port to get logs as 4th parameter. Defaults to '22'"
+ echo "[X] Optional - remote base path to get the logs as 5th parameter. Defaults to '~' (HOME dir)"
echo "Incorrect amount of parameters" >> $LOGFILE 2>&1
exit 1
fi
mkdir -p /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
echo "$(date) ######## Start of rsync to $1" >> $LOGFILE 2>&1
-rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":~/logs /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
-rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":~/downloads /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
-rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":~/profiles /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
-rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":~/data /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
+rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":${5:~}/logs /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
+rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":${5:~}/downloads /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
+rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":${5:~}/profiles /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
+rsync -axv -e 'ssh -p '"${4:-22}"' -o "StrictHostKeyChecking=no" -i /home/redelk/.ssh/id_rsa' "$3"@"$1":${5:~}/data /var/www/html/c2logs/"$2" >> $LOGFILE 2>&1
echo "$(date) ######## Done with rsync" >> $LOGFILE 2>&1
