Save Gmail Attachments Into Google Drive and Delete: CCTV Amcrest DVR Images

Updated: 12/17/2018.

Recently I learned about the change of terms for Flickr, where I save all my CCTV snapshot images coming from my Amcrest 960H HVR. They are triggered when there is movement detected. Granted, not that effective by default, but at least provides me with indications or patterns of something abnormal happening, which can then allow me to search the video recordings (I shall run them against media analytics services at some point).

Point is that I needed to find out an alternative for hosting my images, and no better option than Google Drive. The system already sends out images via email, and I had to figure out how to land them into Google Drive. Luckily I found out this post from Andreas Gohr, where he provides a script that takes Gmail attachments and saves them into Google Drive.

On a high level, the solution relies on two processes:

  1. Rule within Gmail that treats the incoming email
  2. Script that runs asynchronously, finds emails and copies the attachment to Google Drive.

The processes are well documented in Gohr’s post.

I took the original code, and modified to suite my needs:

  1. Extract the DVR snapshot attachment image.
  2. Make a copy into a Google Drive sub-folder, using a sub-string. Used the camera number as folder name.
  3. Create subfolder names based on year, month and date provided by the filename (sample: 03_20181202010558.jpg). The folder name will be re-used if it already exists.
  4. Delete the email (as I no longer needed once copied).

My Gmail rule differs a bit from the original poster:

  1. Mute the Conversation (it does not appear in the inbox)
  2. Mark as read (this might be optional)

The script for my code is located here.

Feel free to create your own copy and modify to suite your needs. Just make sure to follow the instructions including the authorization step. This is important as the scripts requires access to Gmail. Google will be sending out an email with “possible risk” to the account, but you can instruct through console that you are OK with the script.

What’s happening in 2011

2010 came by pretty quickly. It has been a very busy year with all kinds of expansions, migrations and consolidations. We installed HP Blade Servers, VMware, SQL Server 2008 R2, Windows Server 2008 R2, CentOS 4.2 X64, F5s, Dell R710s/610s, Dell Equallogic Storage, TFS 2010, Windows 7 X64 for all DBAs and BI developers, etc. The list continues.

So what is happening next year? Many exiting things, with a core focus on HA, DR, Analytics, SharePoint 2010, and VMware on production databases.

On the Database side:

  • Homogenous environment. All instance running under SQL Server 2008 R2 (some edition downgrades in the mix)
  • Isolated Development, QA and UAT environments with proper edition (Developer, Standard, Enterprise). VMWare and MSDN come to play.
  • Management Data Warehouse deployment to collect health information from all production instances. Birds-eye view of all instances in one location.
  • Central Management Servers Implementation
  • Policy Based Management Implementation
  • Data-Tier Application Implementation
  • RML utilities for pre-production load testing
  • PowerShell

On the Analytics side:

  • All legacy cubes migrated to SQL Server Analysis Services 2008 R2
  • Deployment of Star Schemas for the remaining business units
  • Dedicated instance for transformations (SSIS)
  • Fire up 3rd and 4th VM for our Scaled-out Deployment of Reporting Services
  • Mastering DAX. PowerPivot for Excel 2010
  • GUI implementation for browsing our cubes. We are in the process of evaluating products.

High Availability & Disaster Recovery:

  • All instances to be moved to HA (2, 3, 4 node clusters). No more single point of failures.
  • Zero-Downtime database migration with Mirroring
  • Block Level Backup and restore offsite
  • Full-Log-Daily Differential Backups across the board.
  • Backup file test by restoring to our UAT environments

Storage:

  • Footprint Reduction by archiving historical data that can be rolled up
  • Storage Expansion to benefit from the spindle count
  • SSD for the most demanding applications (over iSCSI)

Training:

  • I am encouraging my team members to use twitter, to follow knowledgeable folks and read tweets from the #sqlserver and #sqlhelp hash tags.
  • To Read Blog Posts and subscribe to RSS feeds
  • To attend to SQL Saturdays
  • To buy books (and e-books)
  • To get trained online and if necessary bring someone to get us trained.
  • To attend the SQL Rally 2011 or SQL Pass Summit 2011
  • To read about SQL Server Denali and install on a VM to test.

I see 2011 being an excellent year for us.

Happy Holidays everyone.

2011

SD Card unexpectedly removed [Android]

Today while I was trying to take a picture of my son wearing his costume with my new HTC G2, got the error message “SD Card unexpectedly removed”. I asked myself: how is that possible if the card is inside and even behind the battery.

Before I continued trying, decided to turn off the phone, extract the card, clean the contacts and try again. Everything went well until 20 minutes later; I got the same error again.

I performed the process again, this time thoroughly cleaning the pins on both the G2 and the SD card. I was able to record my son’s parade and even upload to YouTube, but yet again the error message came up once more.

Searched on Google, called a friend and even called T-Mobile to see if there was any known issue. Didn’t get too much help so I went ahead and performed a CheckDisk with repairs (while plugged in to the USB port of my PC). I thought it was fixed after it, but minutes later, again the issue reoccurred.

I decided to use a MicroSD adapter, plugged into my computer, tried to save whatever I could from the latest pictures and videos I took (luckily it was just 2 weeks worth) and formatted it like 3 times. I did not choose a quick format option just to ensure that all blocks get touched.

All good? No. Seems that the card is bad. Called T-Mobile, called, HTC, there are no replacement cards for the HTC G2 yet. What? It is a universal card! But no, HTC says that I need to call when they get stock parts for the HTC G2.

I guess I am out of luck on this one. I will need to buy another card.

Luckily, all the previous contents were safely backed up to the cloud.