My Raspberry Pi - A Web, storage and security server

December 12, 2018, at 11:36 AM by mgarcia in 2018, Blog, Misc (2 comments)

Author: mgarcia Date: 2018-12-12 21:36 +1100 Tags: 2018, Blog, Misc Comments: Open




Size: 949.75 KB

Just a quick post talking about my little Raspberry Pi server.


The Hardware

My old server died in late October when I setup a cron script to remove old security camera captures.
Since then I've been trying to make the most out of it with less, replacing my old desktop server (pictured below) and with a Raspberry Pi Zero, I have.
Originally, I just had it hanging of the router's USB port!

image: Raspberry Pi hanging of the router
My original Raspberry Pi setup

The only issue with this, is the very limited storage via MicroSD or USB thumb drive. So I decided the best solution would be a USB harddrive!

image: My harddrive and Raspberry Pi
My Raspberry Pi - A Web, storage and security server

There's a few things here. Firstly the crappy looking clear speaker wire wrapped around the box is a USB2 Y cable spliced to a USB2 OTG cable.

About the USB2 OTG Y Cable
OTG (On The Go), is a cable (black cable above) which has a microUSB male plug to a full size USB2 female, it's commonly used to attached USB2 devices (ie thumb drives) to mobile phones or tablets.
The Raspberry Pi doesn't draw enough power from the USB2 port to power itself and the harddrive.
So the harddrive has to be powered from another source, which is the Y cable.
The Y cable (clear speaker wire above) is where you splice another USB2 male plug which then powers the USB device plugged into the OTG USB2 female, the harddrive.
They are easy to make or very cheap to buy.

Next, to put the Pi in the box, I had to cut a bit of the top clear plastic, so the cables can be fed into the box.
The exterior of the drive, which the Pi rests on, is plastic, so there's nothing there that can short any connections.
The Pi and the harddrive generate a little bit of heat, but it's not anything to melt or start a fire, it's just warm to touch.

I also got a USB2 power adapter with 2 ports, one for the Pi the other for the Y cable to power the harddrive.

image: My new harddrive
Yes there's a Raspberry Pi zero in there!

The Software

Pretty simple linux setup:
Web Server: Apache2 & pmwiki , 20% loading while serving
File Server: Samba, 20% loading while serving
Camera recorder: 2x openRTSP and 1 avconv (ffmpeg JPEG stream) 12% loading constantly recording

I have 3 cheap IP cameras which are constantly recording, nothing serious, no alerts, no motion detection, etc. These server mostly as a visual deterrent.
Also, I've noticed most people have their security system in obvious places.
Which is really strange to me, because if an intruder enters the house and sees the security system, they would most likely take it also.
I have my Pi box under a couch which is against a wall!

Here is a snap shot of the load, apache2 isn't normally that busy and ranges from 0.2% to 30%. It idles below 1% and this blog post loading takes about 25% to load.

image: My new harddrive front
Server load
The Pi loading mostly sites at-

top - 08:37:21 up 16:35, 1 user, load average: 0.79, 0.76, 0.75
Tasks: 94 total, 3 running, 62 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5.1 us, 16.8 sy, 0.0 ni, 74.3 id, 0.0 wa, 0.0 hi, 3.8 si, 0.0 st
KiB Mem : 443872 total, 30164 free, 67000 used, 346708 buff/cache
KiB Swap: 102396 total, 102396 free, 0 used. 307272 avail Mem

It's a fare bit slower compared to my old desktop, which is to be expected but it's a worthy compromise!

I'm not a linux expert, but here are the two main scripts I use:

Warning: These scripts are pretty hacky, so here for educational purposes only - Use at your own risk.

Camera recording
This script captures a stream in the background and every hour it terminates capture and then repeats, but it doesn't auto delete archives!
The script is executed via initab at boot up.

Website backup
Having good backups is important and with a huge harddrive, there's no excuse!
This script archives my website into a tar file and archives it where it's accessible via samba (/mnt/usb).
The script is executed via crontab every 5 hours.

crontab -e

# m h dom mon dow command
* */5 * * * /var/www/mgarcia/sitemap.sh /dev/null 2>1
@reboot /mnt/camRoot.sh

Thanks for reading.
PS: If you have a comment or feed back, please leave it below, I may miss it on my social media feed.
mgarcia


2 comments on "My Raspberry Pi - A Web, storage and security server"

  • capjamesg (jamesg.blog): 2020-09-24 14:57 +0200
    Hello Mike, I love your website! I've considered setting up a Raspberry Pi home server for a while but I haven't found the confidence to go ahead with the project. How much time do you spend administering your website, if any?

    Email: jamesg@jamesg.blog.
  • mgarcia: 2020-10-01 15:06 +0200
    replied via email:

    I haven't really 'maintained' it, I use flat file CMS's so no database.
    If you mean spam posting? I used to on my old CMS (flatpress), but the spammers need working links, my comments allow links, but they're not active, so they don't bother.



Comments are open.


Your name or alias (required):

Your plain text comment (required):


Your entered name and comment will be displayed above this form.
There is no reply notifications or editing of comments.

 Enter value: 3917  



RSS Feed @mgarcia_org Twitter Feeder my random Youtube videos
← An IndieWeb Webring πŸ•ΈπŸ’ β†’



Page last modified on October 01, 2020, at 03:06 PM and visited 4350 times.

Powered by PmWiki