Speeding up database access

This is a very thorough article on ways to speed up a SQL database by Matt Perdeck

Speeding up database access – Part 1: Missing indexes

backup of VMWare using ghettoVCB.sh

You can back up VMware VM for free using ghettoVCB.sh script. Everything you need is here:

https://github.com/lamw/ghettoVCB

I was unable to download it directly to the the VMware server because wget v1.19 refused to download form https:// url.

Instead I downloaded the file to my Windows machine and used WinSCPPortable to upload the file to the server.

To extract the files do:

unzip ghettoVCB-master.zip

Go to ghettoVCB-master folder and make the scripts executable:

chmod +x ghettoVCB.sh
chmod +x ghettoVCB-restore.sh

Add a new NFS share as a datastore “backup”. This is where we are going to store the backup files.

Create some folders and configuration files. A typical way to execute the script is:

./ghettoVCB.sh -f vms_to_backup -g global_config/vm_global.conf

To schedule a cron job add the following line to /var/spool/cron/crontabs/root

0 0 * * 1-5 /scratch/ghettoVCB-master/ghettoVCB.sh -f /scratch/ghettoVCB-master/vms_to_backup -g /scratch/ghettoVCB-master/global_config/vm_global.conf > /vmfs/volumes/backup/ghettoVCB-backup-$(date +\%s).log

Then add the following to /etc/rc.local.d/local.sh

/bin/kill $(cat /var/run/crond.pid)
/bin/echo “0 0 * * 1-5 /scratch/ghettoVCB-master/ghettoVCB.sh -f /scratch/ghettoVCB-master/vms_to_backup -g /scratch/ghettoVCB-master/global_config/vm_global.conf > /vmfs/volumes/backup/ghettoVCB-backup-\$(date +\\%s).log” >> /var/spool/cron/crontabs/root
crond

In order to allow the script to send emails you need to:

Step 1 – Create a file called /etc/vmware/firewall/email.xml with contains the following:


  
    email
    
      outbound
      tcp
      dst
      25
    
    true
    false
  

Step 2 – Reload the ESXi firewall by running the following ESXCLI command:

~ # esxcli network firewall refresh

Step 3 – Confirm that your email rule has been loaded by running the following ESXCLI command:

~ # esxcli network firewall ruleset list | grep email
email                  true

Step 4 – Connect to your email server by using nc (netcat) by running the following command and specifying the IP Address/Port of your email server:

~ # nc 172.30.0.107 25
220 mail.primp-industries.com ESMTP Postfix

To perform a dry run restore do:

./ghettoVCB-restore.sh -c vms_to_restore -d 1

To perform a real restore do:

./ghettoVCB-restore.sh -c vms_to_restore

How to prune raspberries

This is a pretty informative video about pruning raspberries and prepare them for the winter:

Useful Linux Commands

Delete all files with given extension recursively:

find . -name "*.dll" -print0 | xargs -0 rm -rf

Find the number of .jpg file in the current folder and all sub-folder recursively:

find . -name "*.jpg" -print | wc -l

Move all .m2ts files to /mnt/backup/m2ts folder:

find . -iname "*.m2ts" -type f | xargs -I '{}' mv {} /mnt/backup/m2ts

Install GUI on Ubuntu Server

sudo apt-get upgrade
sudo apt-get install ubuntu-desktop

Find out the disk usage

df -h

You can free up some space in /boot by removing old kernel with:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

according this post

Search for a string in all text files:

find folder_name -name '*.txt' -exec grep -i 'text-to-search-for' {} \; -print

Search for all .jpg files modified (taken) in the last year and move them to another folder:

find . -iname "*.jpg" -mtime -365 -print -type f | xargs -I '{}' mv {} /mnt/backup/jpg_last_year

Delete .jpg files older than 1 year:

find . -iname "*.jpg" -mtime +365 -print -type f | xargs -I '{}' rm {}

Delete .jpg images smaller than 500KB

find /mnt/backup/_wd3 -iname "*.jpg" -size -500k -delete

Move all .jpg files modified in 2013 to a separate folder:

find . -iname "*.jpg" -newermt "2013-01-01" ! -newermt "2013-12-31" | xargs -I '{}' mv {} /mnt/tank/common/multimedia/pictures/jpg_3/2013

FreeNAS and Couchpotato

A good guide is available here:

Freenas 9.2.0 with Transmission and Couchpotato/Sickbeard as a DLNA-Server

[How-To] Transmission & FreeNAS Shared Mount Points

There is a great tutorial on how to set up FreeNAS with Transmission on the FreeNAS forums:

[How-To] Transmission & FreeNAS Shared Mount Points

You don’t currently have permission to access this folder

Recently I had to rescue a data from NTFS partition for somebody. It was a totally messed up laptop that could not boot the OS. It comes with a hidden partition from which you can restore the system and in theory to preserve the existing user data.

I did not want to take any risks though. Instead I removed the disk and put it in a USB 3.0 enclosure and connected it to my laptop in hope I can copy the data. Although I was able to see the folder structure and open some folders there were many I could not access. I was getting pop-up saying “You don’t currently have permission to access this folder.”

Luckily I was able to find a solution on Clint Boessen’s Blog.

There are 3 settings in the Local Security Policy related to the problem:

User Account Control: Admin Approval Mode for the Built-in Administrator account - Disabled
User Account Control: Behaviour of the elevation prompt for administrators in Admin Approval Mode - Elevate without prompting
User Account Control: Run all administrators in Admin Approval Mode - Disabled

The correct settings are in bold.

In my case the first two had the correct settings already but I had to change the last one which solved the problem – I was able to copy the data to a backup location.

HTTP Error 503. The service is unavailable

I recently had a problem with IIS on Windows 7 where trying to access http://localhost on the default port 80 was giving me an error:

“HTTP Error 503. The service is unavailable”

I spent several hours trying to find the cause and trying different things without any success.
Finally I came across this post that helped me resolve the problem.

The root cause was an URL Reservation http://+:80/

To remove the reservation type the following in a command prompt (but first read the post to know what your are doing):


netsh http delete urlacl http://+:80/