Mount USB stick (backup stick)

#format SD card
mkfs.ext4 /dev/sda
vim /etc/fstab

(info) configure fstab to skip mount errors because if USB stick is not available boot fails or is really slow due to mount timeout (default seemsto be 90 seconds). More info at

/dev/sda        //mnt/external_usb32g     ext4    defaults,nofail,x-systemd.device-timeout=5        0       0
mkdir -p /mnt/external_usb32g
mount -a

cd /
ln -sf /mnt/external_usb32g backup

Troubleshooting USB stick file system

vim /opt/
umount /mnt/external_usb32g
fsck -y /dev/sda
mount -a
chmod +x

Daily repair cronjob

vim /etc/cron.d/repairusbstick
#daily repairing of USB stick
0 6 * * * root /opt/ > /dev/null 2>&1

Daily Backup

(info) Backup runs daily at 18:15 (after daily regular closing of the museum)


15 18 * * * root /opt/ > /dev/null 2>&1



CUR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
DTS=$(date +"%Y%m%d_%H%M")

#rsync switches
# D - keep device files
# o - copy owner rights
# g - copy group rights
# r - recursive
# R - copy with folder structure
# L - copy files behind symlinks
# t - keep timestamp
# l - copy symlinks
# p - keep file permissions
# a = Dgloprt

#installed packages
dpkg -l > "$BUP"/dpkg.list

#some extra options for all rsync - can be used to debug
#RP="-v --progress -stats"
RSYNC="rsync $RP"

#home, skel, postfix, apache, motd, ssl, init.d, systemd, resolv.conf, interfaces, ...
$RSYNC -lrR /home/     "$BUP"
$RSYNC -aRL /etc/      "$BUP"
$RSYNC -rptR /boot/        "$BUP"

$RSYNC -laRL /var/spool/cron/crontabs/ "$BUP"

$RSYNC -lrptR /usr/local/      "$BUP"

#get host-specific backup jobs
$RSYNC -lrptR /var/lib/Repetier-Server/ "$BUP"
$RSYNC -lrptR /usr/local/Repetier-Server/ "$BUP"
$RSYNC -lrptR /usr/local/Repetier-Setup/ "$BUP"
$RSYNC -lrptR /usr/local/share/mjpg-streamer/ "$BUP"

$RSYNC -lrptR /opt/ "$BUP"

#sh usage of /backup
SIZE=$(cd "$BUP";echo $(du --apparent-size -sh)|cut -d ' ' -f1) #use apparent size to display correct size of NAS! otherwise ~200 MB will show as ~3.5 GB

printf "[$DTS] rsync-Backup of $(hostname -f) was done! \nSize:"$SIZE"" | mail -s "$(hostname -f)" target@mail.address

Remote Backup

(info) Additionally a remote host is copying the backup files by pulling with rsync over SSH.

Cleaning old InfluxDB dumps


0 21 * * * root find /mnt/external_usb32g/db/ -mtime +14 -exec rm {} \; > /dev/null

Troubleshooting Postfix (Restart Postfix)

Because sometimes mailq is not emptied we are going to force sending out mails every 5 minutes. Sometimes the message "postqueue: warning: Mail system is down -- accessing queue directly" is shown when typing command "mailq".


*/5 * * * * root systemctl restart postfix

Send dmesg log by mail

/etc# cat rc.local

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

# send dmesg log by mail once per reboot
dmesg | mail -s "dmesg log from session" target@mail.address

exit 0

Switch off LED stripes and spot from Trikarus

(info) Saves energy and prolongs the life of the LEDs


# this script switches off the LED stripes and spot from Trikarus at 18:00 every day
0 17 * * *     root  python3.7 /opt/gpio/

Switch on LED stripes and spot from Trikarus

(info) See

This script switches on the LEDs once per hour. It should not autotrigger every minute because the userdefined request to turn them off should be respected too (from bash or from Repetier Server UI)!


# this script switches on the LED stripes and spot from Trikarus
#"At every minute past every hour from 9 through 17 on Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday."
0 9-17 * * 2,3,4,5,6,7  root  python3.7 /opt/gpio/
  • No labels
Write a comment…