All posts by Matt

Restore a single file from a QNAP CloudStation Backup on Google Cloud

QNAP adding support for Google Nearline with their CloudBackup Station was a watershed moment for me in cloud backup.   I refused to do cloud backup before due to cost, security concerns and ease of use.

Nearline addresses my cost concerns since it free to upload, low cost to store ($.01/GB/mo) and considering this is for disaster recovery the download cost could be 100x and I’d still pay.

CloudBackup Station addresses my ease of use and security concerns since it connects to the cloud using SSL and offers strong client side encryption.   However you must enable the encryption when setting up the backup job and pick a long password to get full advantage.

But what if you want to restore just one file?   CloudBackup Station doesn’t support that — its all or nothing, but there is a relatively easy workaround though.

  1. Go to https://console.developers.google.com/
  2. Click on the project name associated with your back up
  3. In the left menu click Storage – Cloud Storage – Storage Browser
  4. In the right pane click the storage bucket associated with your back up
  5. Navigate to the file you want;   The bucket should mirror the directory structure on your NAS.
  6. Download the file
  7. The file won’t open because you encrypted it, right?   Move it to a directory on your NAS
  8. SSH into your NAS and navigate to that directory
  9. Type:
 openssl enc -d -aes-256-cbc -k %password% -in '%downloaded_encrypted_file%' -out %outputfile%

You could perform the decryption on your computer as well since openssl is available for a variety of platforms, but we know its on your NAS and the syntax is known.

References:

 

Night latch repair plate

Do you have locks like this?

They’re usually called Night Latches and are pretty common in older buildings.   They’re great since its only 5 screws to change the lock cylinder/key without the need for a locksmith.   This one is spring loaded, so it will lock behind you (they also sell regular dead bolt versions).

However being used in older houses and given that their latch is spring loaded (slam, slam, lock?) the door frame gets abused and sometimes cracks.   The whole thing could be moved down the door, but that would be ugly with unused slots/holes in the frame/door.

After looking and looking for a repair striker plate similar to this one:

 I gave up and made my own.

repair_plate

DXF in RAR

It works with 1.25″ thick doors or thicker.   Make you own from the DXF or I made a bunch and will send you one for $24 (my cost) + shipping.

So I need an 11 second Mustang

 

Based on the results of the $2013 Challenge I need an ~11 s car to win the drag.

Turning to an ET-MPH-HP calculator I need to make 327 hp assuming a weight of 2200 lbs (10% reduction of stock weight).   Going to another on-line calculator to convert RWHP to Crank HP I get 400 bhp at crank.

According to Wikipedia the stock motor makes 271 bhp, so I’d be looking to get 150% more given the load of the alternator and water pump.

289 cu in (4.7 L) Windsor HiPo V8 (1964–1966) 4-barrel 271 bhp (202 kW; 275 PS) @ 6,000 312 lb·ft (423 N·m) @ 3,40

The guys at vintage-mustang say its possible and the motor already has many go fast parts that I have to quantify.   Gotta get it ready for Epping in the spring…

Quick script to add things to crontab

Out of all the options I’ve found manually adding items to crontab in an editor is the best… despite all the typing.   I made a quick script to cut down on the typing.

#!/bin/bash
nano /etc/config/crontab
read -p “Press [Enter] if you’re sure…”
crontab /etc/config/crontab
/etc/init.d/crond.sh restart
echo “Confirm change”
crontab -l

It also allows me to avoid vi.   You must have nano installed for this to work or replace with your editor of choice… even vi.

Exit the editor without saving and Control-C out of the script at the pause if you messed up.

How to log Humidity data from your NEST

Based on my success in getting my NEST to SMS when my furnace fails I wanted to get into something else that bugs me about the NEST.   It knows the humidity in the house, but its tedious to get it to tell you… click, click, click on either the NEST or the app or the website.

What I’ll do with data?  I’m not sure.   Perhaps justify a whole house humidifier some day or running a window A/C in dehumidify mode or figure out when to buy vats of hand lotion…

#!/bin/bash
#
# By M. De Remer 2014
#
# Inspired by the article by Scott Baker and comments at
# http://www.smbaker.com/a-python-api-for-the-nest-learning-thermostat
#
# Remember to make these file(s) executable ‘chmod +x hum_log.sh nest.py’
#
# More at http://www.EngineerItDude.com
#
# Remember to add this to /etc/config/crontab
#
# Requirements
# – Python
# – nest.py
# – a NEST
#
# Change these items to match your accounts
#
# Nest Login info
USERNAME=”you@you.com”
PASSWORD=”supersecretpassword”
#
# Install path
NPATH=”/share/HDA_DATA/.qpkg/nest”
#
# Don’t change anything below here unless you know what you’re doing
#
echo “HumLog started at $(date)”
#
# Set rarely changed variables
LOG=”$NPATH/hum_log.txt”
CTF=$(python $NPATH/nest.py curhumid –user $USERNAME –password $PASSWORD)
CTFR=$(echo $CTF | cut -d”.” -f1)
#
#
if [[ -z $CTF ]]
then
echo “Alert: NEST has not responded or another error has occured”
log_tool –append ‘HumLog ERROR’ -t 0
else
echo “Humidty is $CTFR”
echo $(date +”%m-%d-%Y”),$(date +”%T”),$CTFR >> $LOG
echo “Humidty logged. Exiting”
fi

Caveat:   Again I used log_tool to alert on a failure to connect to the NEST.   This is used by QNAP.   Others may use another command.   You can comment this out if desired.

Get SMS alerts from your NEST

As soon as we got our dog the downsides of no central A/C and an antiquated open loop steam heating system with manual refill became apparent.   We already had a NEST.   It knows the house temperature – Its on the internet – Can’t it alert me to a problem?   Googling Nest and e-mail or SMS alerts brings you to a highly upvoted request to add this feature.   Most requests added horror stories of fail heating systems and frozen pipes.

After some more googling I found a post and Python script written by Scott Baker and lots of great comments about how to use the script.

I have an always on NAS, a QNAP TS-219+, that allowed SSH access.   After trying to remember my hay day of shell scripting in college I generate the below, which works!

#!/bin/bash

#
# By M. De Remer 2014
#
# All temperatures is Degrees F
#
# Inspired by the article by Scott Baker and comments at
# http://www.smbaker.com/a-python-api-for-the-nest-learning-thermostat
#
# Remember to make these file(s) executable ‘chmod +x nestalert.sh nest.py’
#
# More at http://www.bayarddesign.com
#
# Remember to add this to /etc/config/crontab
# Suggested entry /[path]/nestalert.sh > /[path]/nestalert.log
#
# Requirements
# – Python
# – nest.py
# – sendmail or similar
# – a NEST
# – an e-mail account or better yet a Email-to-SMS gateway like vtext.com
#
# Change these items to match your accounts
#
# Target E-mail, for multiple recipients add comma between addresses
EMAIL=”you@you.com, yournumber@vtext.com”
#
# Nest Login info
USERNAME=”you@you.com”
PASSWORD=”yourdogsbirthday”
#
# NAS or Nest e-mail from e-mail address
FROM=”NAS@you.com”
#
# Install path
#
NPATH=”/share/HDA_DATA/.qpkg/nest”
#
# Change these limits if you like. Remember the NEST allows for some margin, so set
# these limits 5 deg F or more from your lowest/highest NEST Setting
MIN=55
MAX=90
#
#
# Don’t change anything below here unless you know what you’re doing
#
echo “Nest Alert started at $(date)”
#
# Set rarely changed variables
tmp=”$NPATH/tmp.txt”
SUBJECT=”NEST ALERT”
MIMEVersion=”1.0″
CONTENTType=”text/html; charset=us-ascii”;
CTF=$(python $NPATH/nest.py curtemp –user $USERNAME –password $PASSWORD)
CTFR=$(echo $CTF | cut -d”.” -f1)
#
rm $tmp
#
if [[ -z $CTF ]]
then
echo “Alert: NEST has not responded or another error has occured”
log_tool –append ‘NestAlert ERROR’ -t 1
else
echo “Current Temperature is $CTFR”
#
if test $CTFR -gt $MIN
then
echo “OK, NEST tempature above $MIN”
else
echo “Alert: NEST tempature $CTFR is under $MIN”
BODY=”NEST ALERT: Temp is $CTFR”
echo “Sending alert e-mail”
echo -e “To: $EMAIL” > $tmp;
echo -e “From: $FROM” >> $tmp;
echo -e “Content-Type: $CONTENTType”>>$tmp;
echo -e “MIME-Version: $MIMEVersion”>>$tmp;
echo -e “Subject: $BODY”>>$tmp;
echo -e “Body: $BODY”>>$tmp;
touch $tmp && chmod 600 $tmp;
sendmail -t < $tmp
log_tool –append ‘NestAlert sent alert for low temp’ -t 0
fi
#
if test $CTFR -lt $MAX
then
echo “OK, NEST tempature below $MAX”
else
echo “Alert: NEST temperature $CTFR is over $MAX”
BODY=”NEST ALERT: Temp is $CTFR”
echo “Sending alert e-mail”
echo -e “To: $EMAIL” > $tmp;
echo -e “From: $FROM” >> $tmp;
echo -e “Content-Type: $CONTENTType”>>$tmp;
echo -e “MIME-Version: $MIMEVersion”>>$tmp;
echo -e “Subject: $BODY”>>$tmp;
echo -e “Body: $BODY”>>$tmp;
touch $tmp && chmod 600 $tmp;
sendmail -t < $tmp
log_tool –append ‘NestAlert sent alert for high temp’ -t 0
fi
fi
echo “Nest Alert Exiting”

A few caveats:   QNAP uses sendmail and log_tool.   You may need to use or install different programs on another brand, but the syntax should be the same or similar.

To test the script set one of the temperature limits near room temperature (i.e. MIN=75 while room temp is 68).

Now no more contant checking of the mobile NEST app or website during heat waves…