Tag Archives: remote

How to configure remote log servers with rsyslog?

Rsyslog is an open-source software utility used on UNIX and Unix-like computer systems for forwarding log messages in an IPnetwork. It implements the basic syslog protocol, extends it with content-based filtering, rich filtering capabilities, queued operations to handle offline outputs,[2] support for different module outputs,[3] flexible configuration options and adds features such as using TCP for transport.


pico /etc/rsyslog.conf


# provides UDP syslog reception module(load="imudp") input(type="imudp" port="514")
Code language: PHP (php)


# # Include all config files in /etc/rsyslog.d/ # $IncludeConfig /etc/rsyslog.d/*.conf if $fromhost-ip startswith '' then /var/log/switch-10-20-26-5.log if $fromhost-ip startswith '' then /var/log/switch-10-20-6-12.log if $fromhost-ip startswith '10.20.' then /var/log/switches.log
Code language: PHP (php)


/etc/init.d/rsyslog restart

Configure the remote switch maybe (like cisco sg300 or cisco 2960 or other)
with log server (the IP of your Linux machine) UDP port 514 Facility Local 7 Description if you like and minimum Severity Notice
If you want to access the logs with apache

chmod -R go+rX /var/log/
Code language: JavaScript (javascript)

Here is a simple php script for apache /var/www/html/log.php

<?php $output = shell_exec('tac /var/log/switches.log'); echo "<pre>$output</pre>"; ?>
Code language: HTML, XML (xml)

.tar.gz /var/www and vardump mysql database and scp ssh to another server – simple backup solution

First things first. With this small and simple tar command we archive all our /var/www/ data.

tar -zcvf archive.tar.gz /var/www
Code language: JavaScript (javascript)

Now we dump the MySQL database with the next command.

mysqldump -u root -p databasename > /root/backupname.sql
Code language: JavaScript (javascript)

You will be asked to write the password for the database user (in this case root).

scp archive.tar.gz root@destinationserver:/root scp /root/backupname.sql root@destinationserver:/root

Again you will be asked twice for the password of the remote server but all your sensitive data will be saved there.
Again this is a very simple and just a small demonstration of what you can do with tar, scp and ssh.