Tuesday, October 22, 2019

Directions to accomplish anything

I know you've always wanted to do something really difficult and time consuming and you just don't know where or how to start. Well, here's your dream come true. In the following post, I will give you directions on how to do just that - accomplish ANYTHING.
  1. Decide what you want to accomplish.
  2. Get together all of the things that you need to accomplish this task.
  3. Plan out how you will accomplish the task.
  4. Proceed to accomplish the task.
There you go. Complete instructions on how to do ANYTHING. You're welcome.

Tuesday, April 9, 2019

snmpwalk commands!

I use SNMP at work quite a bit and I have to issue snmpwalk commands fairly often to trouble shoot monitoring.

Here are a couple examples using SNMP v2c and v3.

SNMP V3 with authentication
snmpwalk -v3 -l authPriv -u USERNAME -a MD5 -A "PASSPHRASE" -x AES -X "PASSPHRASE" device.domain.com

SNMP v2c

snmpwalk -v2c device.domain.com -c SNMPString

Sometimes you need to redirect this to a file for better searching and reviewing.

 snmpwalk -v2c device.domain.com -c SNMPString > mibtree.txt 2>&1

That will do it without any errors or unwanted output.

Sunday, February 17, 2019

Google Drive Offline Backup with Raspberry Pi

So, after retiring my Mac Mini earlier this year, I lost my ability to keep an offline backup of my Google drive files. I recently realized that I could put something together with my Raspberry Pi. Here is what I cobbled together.

I updated to the latest version of Raspian and installed the following with apt-get.


I also spent the $5 on OverGrive for Linux to sync Google Drive to my Pi. They have very good instructions and I didn't have any trouble with that part. It took a couple hours to sync up but works well after the initial download.

Then I plugged in my USB drive and it took a few tweaks to get it working right and writable after a reboot. I followed this page but didn't have to add the delay part at the end.


Basically, find the block ID of the USB drive.

sudo blkid

# /dev/sda1: LABEL="ELEMENTS" UUID="E033-1109" TYPE="vfat"
Create a new mount point.

sudo mkdir /mnt/usbel  
Take ownership.

sudo chown -R pi:pi /mnt/usbel  
Add the appropriate line to the fstab (update with your blockid and mount point). I installed 'ntfs-ng' for my USB drive and changed 'vfat' to 'ntfs' as well.

UUID=E033-1109 /mnt/usbel vfat auto,users,rw,uid=1000,gid=100,umask=0002 0 0  
Test it with a 'mount -a', adjust accordingly, reboot for a test.

I installed 'ssmtp' and 'mailutils' as well to send me a report of what gets updated. Installing these was a bit tricky with Google authentication. You will just have to search for the answers as I am sure they will change and might be different depending on your Google account. I had to enable two factor auth and generate an App Password for the outgoing mail to work. You can create a special email account for this just to send email if you don't want to mess with your default gmail account.

Next, add the rsync command to your crontab. It should look something like this.

0 5 * * * /usr/bin/rsync -avh --delete /home/pi/Google\ Drive/ /mnt/usb/GoogleBackup | mail -s "Google Drive Rsync Report" user@domain.com

It might be a good idea to manually test the rsync command and complete a copy first to avoid an errors that might take place.

I have other versioning systems in place for the live copy of my Google Drive (aside from the archives and recycle bin provided by Google). This one give me the peace of mind of having one on a USB drive I could grab in an emergency. Not that grabbing the entire Raspberry Pi would be much different. I guess this was also just fun to do.