Skip to content

Instantly share code, notes, and snippets.

@solusipse
solusipse / crontab
Created March 21, 2016 12:19
Simple backup solution - rsnapshot
# on backup server
0 */4 * * * /usr/bin/rsnapshot hourly
30 3 * * * /usr/bin/rsnapshot daily
0 3 * * 1 /usr/bin/rsnapshot weekly
30 2 1 * * /usr/bin/rsnapshot monthly
# This is a very simple script for performing whole disk backups. Rotation scheme: 3 daily backups, 2 weekly and 2 monthly.
# Edit to suit your needs. The only non-standard requirement is sshfs.
TARGET="1.1.1.1"
MAIL="[email protected]"
sshfs root@$TARGET:/backup/disk /root/mnt
if [ $# -eq 0 ]; then
echo "Run with argument: daily, weekly or monthly."
exit
@solusipse
solusipse / pgsql_backup.sh
Created January 9, 2016 09:53
postgresql backup
#!/bin/bash
# remember to set local to trust in pg_hba.conf
sudo -u postgres pg_dumpall | gzip -c > /backup/db.sql
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Database backup failed at domain.com!" | mail -s "Backup error" [email protected]
fi
chmod 0600 /backup/db.sql
date > /backup/last.txt
@solusipse
solusipse / gist:b3a13e6578d97db97c27
Created October 6, 2015 03:50
esp8266 exception codes
Cause code Name
0 IllegalInstructionCause
1 SyscallCause
2 InstructionFetchErrorCause
3 LoadStoreErrorCause
4 Level1InterruptCause
5 AllocaCause
6 IntegerDivideByZeroCause
7
@solusipse
solusipse / esp8266-connect-to-ap.md
Created August 12, 2015 09:19
ESP8266: connect to access point
AT
AT+CWMODE=1
AT+CWLAP # scan for wireless networks
AT+CWJAP="ssid","password"
AT+CWJAP? # check if connected
AT+CIFSR # get ip

Rasbperry PI DS18b20 in parasitic mode (2 wires only)

Add to /boot/config.txt following line:

dtoverlay=w1-gpio,gpiopin=4,pullup=on
@solusipse
solusipse / geovision.md
Created June 28, 2015 03:00
Geovision camera (GV-MFD520) RTSP streaming to linux machine

For a while, I used an ftp connection to download videos from my geovision camera (used in home surveillance system). But due to often power outages in place where I live, I had constantly repeating problems with an sd card which was used as an intermediary between camera and linux-powered station. It made me to look for other solutions. I switched to RTSP protocol and now it works flawless. If you're a geovision camera owner and building your own recording station, you might find that draft helpful. First of all, you have to enable RTSP server in your camera's panel. Then you can for example use VLC to check if it works properly. In my case proper address of stream was: rtsp://192.168.1.73:8554/CH001.sdp I used cron to execute script with such line every 10 minutes: avconv -i rtsp://192.168.1.73:8554/CH001.sdp -c copy -t 610 /mnt/videos/$(date "+%d-%m-%Y-%H:%M:%S").mp4 610 is for time here (610 seconds). Extra 10 seconds are just in case, sometimes first 3-5 seconds are broken. I also configured nginx to

@solusipse
solusipse / doddns.py
Created June 22, 2015 11:05
Own DDNS service on Digital Ocean
'''
doddns
This script was made for using a Digital Ocean's droplet as a ddns service.
[!] Remember to put your credentials below.
[!] Script needs requests library. To install it use pip: pip install requests.
Before you'll start, check if it works properly with your config. Simply run it:
python doddns.py
@solusipse
solusipse / grubmanual
Last active August 29, 2015 14:23
manual booting with grub
set root='(hd0,1)'
linux /boot/vmlinuz-linux root=/dev/sda1
initrd /boot/initramfs-linux.img
boot
@solusipse
solusipse / gist:fe4e29a190f625297726
Created October 25, 2014 18:58
delete old mails from junk
find /home/vmail/*/*/.Junk/cur/* -mtime +14 -exec rm {} \;