Sunday, December 22, 2013

Networked Time Machine Backups on Mountain Lion

I need to upgrade my Macbook Pro to Mavericks. But I need to backup my Mac before that. The best way to do that is via Time Machine. The only problem is Time Machine requires a local hard disk and the only ones I own have terabytes of data on them and are NTFS formatted.

So I decided to get Time Machine running over the network.

I found some guides here:
This doesn't work on Mountain Lion unfortunately - for some reason Time Machine on Mountain Lion won't show unsupported Network drives.

Fortunately I found this guide which led me to the tmutil utility.

Also I found Time Machine was creating "snapshots" on the local hard disk which was using up hard disk space. This can be disabled via tmutil disablelocal

So, from start:
  1. Open Time Machine preferences, click on Options
  2. Exclude everything you don't need. I excluded everything except my Home Folder. In my Home folder, I exclude ~/Library/Caches, ~/Applications, SteamApps folder and ~/Library/Developer/Shared. You should also include /.DocumentRevisions-V100 folder as this supports the Auto Save/Versions functionality. My final backup size is just 10 GB after excluding all media folders in my Home folder.
  3. See the estimated size of the full backup and create a sparse disk to approximately 5 times that size
  4. Copy the sparse disk to your Windows share
  5. Mount the Network Drive using Samba
  6. Mount the Sparse Disk using hdiutil
  7. Use tmutil to set the sparse disk as a destination for backup, enable time machine and disable local snapshots
  8. Use tmutil to start the backup
  9. After the backup, you can show Time Machine in Menu Bar and Enter Time Machine from your Hard Drive root to see what all is being backed up.
  10. Unmount the sparse disk and network share
I created a Bash shell script for all the functions, including creating the sparse bundle:
if [ "$1" == mount -o "$1" == all ]; then
    echo "Creating mount folder"
    sudo mkdir $MOUNTPOINT
    echo "Mounting Samba"
    sudo mount_smbfs -o nosuid,nodev $NETWORKSHARE $MOUNTPOINT
    echo "Attaching Sparse Disk"
    sudo hdiutil attach $MOUNTPOINT/$SPARSEBUNDLE.sparsebundle/
if [ "$1" == enable -o "$1" == all ]; then
    echo "Setting Destination..."
    sudo tmutil setdestination /Volumes/$SPARSEBUNDLE/
    sudo tmutil enable
    sudo tmutil disablelocal
if [ "$1" == backup -o "$1" == all ]; then
    echo "Starting Backup..."
    sudo tmutil startbackup --block
if [ "$1" == unmount ]; then
    echo "Detaching Sparse Disk"
    hdiutil detach /Volumes/$SPARSEBUNDLE/
    echo "Unmounting Samba"
    sudo umount $MOUNTPOINT
if [ "$1" == createblankdisk ]; then
    echo sudo hdiutil create -size "$2"G -fs HFS+J -volname "$3" "$3".sparsebundle
if [ "$1". == . -o "$1" == --help ]; then
    echo Time Machine Manager Script
    echo Options:
    echo all - Mount Remote HDD, Setup Time Machine, Create Backup
    echo mount - Mount Remote HDD
    echo enable - Setup Time Machine
    echo backup - Create Backup
    echo unmount - Unmount Remote HDD
    echo createblankdisk SIZE_IN_GB NAME - Create a blank disk with requested size in current folder. The created file has name NAME.sparsebundle
    echo "Done"

Note normally you just have to give mount, enable and backup once. After that you just need to use mount and unmount. Time Machine should auto backup on mount, or you can run backup manually. (You can also use the Backup Now menubar entry for Time Machine)

To stop OSX Auto-Save and Versions functionality, see here and to disable Saved Application State see here (I don't recommend doing that though) In general you can use Grand Perspective or another Disk Space Visualizer to see what are the large sized folders on your mac.

BTW, I found this guide on how to enable NTFS write on OSX. I havent tried it out though.

Saturday, October 12, 2013

Even More Mac Tricks

So one thing I ended up doing was assigning Ctrl-T to Open New Tab and Shift Ctral T to Reopen Closed Tab - I use Ctrl-Tab to switch between tabs and it just feel strange to have to use Cmd-T to open a tab and Ctrl-Tab to switch between tabs. Anyways, here goes.

Networking, VMs and Firewalls

I use Samba to share files with my Windows Machines at home. However, for some reason, the PF firewall on my Mac does not allow SMB connections through. While it is possible to load custom rules into PF using Icefloor or manually, its often simplest just to disable PF as:
sudo pfctl -d
and when you are done, re-enable it as:
sudo pftcl -e

Another option: Use a VM. You can setup a Ubuntu VM with Bridged Networking, setup Shared Folders between your Mac and the VM and then share things on the VM via SMB. It works out way better than Mac's SMB implementation (in Lion, Apple switched to their own SMB implementation to avoid having to comply to GPLv3) This is not recommended unless you have a Mac with at least 8 GB of RAM.

Another nice feature of bridged networking: it bypasses VPN so your VM will be outside the VPN even when your host is inside the VPN. I generally setup multiple network cards in my VM, one with NAT, one with Bridged and then connect the relevant card depending on what I want to do with the VM. Disadvantages of Bridged Networking: you will need to add your VMs MAC to any WiFI MAC filter if you have enabled it in your Router and it does not work with GSS/Cert based networks. And obviously, it doesn't work over VPNs.

Other Mac Weirdness

For some reason, every time I connect to another Linux machine using NX client on my Mac, it keeps switching on the Caps-Lock of the other machine. Now since Caps-Lock is pretty much useless anyway, the cleanest fix I have found to this is to disable caps lock entirely on the target machine.

Then there are NTFS formatted USB HDDs - one of my friends recently gave me his USB HDD to copy some stuff. However while I could read from it, I couldn't write to it. Turns out, Mac turns off Write capability on NTFS drives by default. To get around this, you have to manually create an entry for the drive in fstab. Then when you are done using the drive, you have to unmount it from the command line using the diskutil command.

Final Notes

I have yet to find a good replacement for Visio on my Mac. Omnigraffle looks to be good - lets see, I might get it. Some other interesting stuff I found:
  • How to use your Mac as an Alarms Clock:
  • How to reset your NVRAM:
  • How to reset your SMC:

Thursday, September 19, 2013

More Mac Tips and Tricks

Google Chrome and F5

So for some reason Google Chrome in OSX does not support F5 for refresh. This is easy to fix it turns out:
  1. Open System Preferences > Keyboard > Keyboard Shortcuts
  2. Click on Application Shortcuts in the Left Pane
  3. Click the + button, select Google Chrome as the Application and enter "Reload This Page" as the menu title
  4. Highlight the Keyboard Shortcut field and press F5
Source: (Instructions for Lion are above)

Games on a Mac and Hot Corners

I have Hot Corners enabled on my Mac. When I try to play a Full Screen game, the Hot Corners keep activating. I searched for some way to disable Hot Corners quickly, but none exists. However, it seems this can be done using AppleScript. What it involves is creating an AppleScript that disables and reenables your Hot Corners on the basis of your input. There are a couple of glitches with this: firstly, if you want to modify the Hot Corners configuration to be something different, you have to modify the AppleScript and if you want to setup a Hot Corner to show Notification Center, then it doesn't work via AppleScript.

Here's the AppleScript I ended up using:
 set question to display dialog "Do you Want to Enable Hot Corners?" buttons {"Yes", "No", "Cancel"} default button 3
 set answer to button returned of question
 if answer is equal to "No" then
  tell application "System Events"
   if UI elements enabled then
    tell expose preferences
     set properties of the top left screen corner to {activity:none, modifiers:{}}
     -- set properties of the top right screen corner to {activity:none, modifiers:{}}
     set properties of the bottom left screen corner to {activity:none, modifiers:{}}
     set properties of the bottom right screen corner to {activity:none, modifiers:{}}
    end tell
    tell application "System Preferences"
     set current pane to pane ""
     display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
    end tell
   end if
  end tell
 end if
 if answer is equal to "Yes" then
  tell application "System Events"
   if UI elements enabled then
    tell expose preferences
     set properties of the top left screen corner to {activity:all windows, modifiers:{}}
     -- set properties of the top right screen corner to {activity:show desktop, modifiers:{}}
     set properties of the bottom left screen corner to {activity:«constant ****lpad», modifiers:{}}
     set properties of the bottom right screen corner to {activity:dashboard, modifiers:{}}
    end tell
    tell application "System Preferences"
     set current pane to pane ""
     display dialog "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
    end tell
   end if
  end tell
 end if
 if answer is equal to "Cancel" then
 end if
end repeat

Some useful links on the same:

  • My original inspiration:
  • The repeat comes from here:
  • General Scripting Guidelines:
  • And some more:

Saturday, September 7, 2013

Back Again - After 3 years!

Wow - its been 3 years since my last blog post. Wasn't expecting a wait this long :)

Mostly its been a bit difficult to find things to write about and considering a lot of what you do at a big company is confidential I could use that as an excuse to say I couldn't speak - but then some of the things I worked on have gone Open Source so can't really take that excuse. I guess mostly the reason was I switced to using FB and Twitter and there just wasnt a reason to blog anymore.

My dad recently go onto FB and I setup a blog for him. Check it out here: For a while I had replaced the G+ comments on his blog with FB comments (so my dad is a registered developer now - Ha Ha. Stupid FB only allows FB comments on a blog if you register it as a Application) That made me think of my own long forgotten blog.

So I recently switched to a Mac at work and since I want to keep track of everything I am doing to solve issues, here goes my first entry in 3+ years :)

Getting Tata Photon Working
  • Download the drivers from here:
  • See this post here for more details:
Keyboard Shortcuts

Some useful links
Setup Windows File Transfer

So Mac OSX Lion has replaced Samba with their own implementation. Also for some reason IT hates domain users sharing files. The solution - create a new user, with Sharing Only privileges. Add a group for the new user and add yourself and the new user to that group. Grant the new group access to your home folder (use the Gear Icon in Finder's Info box to add permissions to subfolders also) and then share away. I have found OSX is quite slow while transferring files. The solution:

Outlook on Mac

Now this thing is amazingly painful. Outlook on Mac is general 70% functional. You can't insert tables in EMails - pretty much every advanced action requires you to edit in Word and then Share as HTML EMail. I also hate Outlook reminders, so I sync the Outlook calendar with the system calendar via Outlook Sync Services. One thing I found to be more powerful than Outlook on Windows is the search capability. Outlook is integrated with Spotlight search on Mac. This means you can find all sorts of useful metadata tags on messages. Open the Search Menu, select Advanced > Raw Query and you can enter all sorts of queries. For e.g this one finds all pending meeting invites:
com_microsoft_outlook_has_reminder = 1 && com_microsoft_outlook_author_email_addresses != *_YOUR_EXCHANGE_ID_@* && com_microsoft_outlook_recpient_email_addresses = *_YOUR_EXCHANGE_ID_@* && kMDItemDisplayName != Accepted:* && kMDItemDisplayName != Declined:* && kMDItemDisplayName != *Notification:*

Some useful links:

Sunday, May 30, 2010

Disabling Message Recall in Outlook

Converted from a Google Wave to normal HTML since Wave is shutting down...

Blog Post - 27 May 2010
So this is a test of embedding a Wave in my blog. I have wanted to try to embed a Wave inside my blog for quite some time - lets see how it goes!

Recently someone at work sent a stinker on a group with a large number of people. When he realized his mistake, he recalled it - it didn't go away from some of my friends' inboxes, but it did go away from mine. Usually, a message is recalled for one of two reasons
  • Unintentional Transmission - Someone sent off a message to you when they didn't want to
  • Post-Stinker Regret - Someone sent of a stinker, then had a moment of panic when his anger subsided

In either case, a recall attempt is usually a source of hilarity - even if its momentary.

Only thing is, if the admin has enabled recalls on the exchange server, it is not possible for you to disable recalls from inside of Outlook. This has happened to me several times and I really don't like people deleting mails that have reached my inbox without my permission - thanks for this Super Creepy "feature" M$! After a bit of research, I found this page which defines the rules of recall.

What this page basically says is that if you disable "Process Requests and Responses on Arrival", Outlook will no longer automatically delete messages on recall. If you just preview mails (in the preview pane), rather than double-clicking to open them, no deletes will happen. Recall requests will show up as a message. If you open the newer message first, the older one - the one with all the content will be deleted. However, it also says that if the recall and the original message end up in different folders, a could not recall message will be sent to the original sender. So now we just need some difference between the recall and a normal message to allow us to distinguish between them. One obvious difference is that the message begin with the String "Recall". However, a perfectly valid message may begin with that. On looking at the headers of the message however, another difference emerges: Recall messages have the phrase "iso-8859-1" in the Subject header.

This gives us the basis of disabling message recall on Outlook. Follow the steps below and message recalls will no longer work:
1. Inside Outlook, Go to Tools>Options. Click on the Email Options button. Click on the Tracking Options button
2. Uncheck the Process Request and Respones on arrival checkbox, click on the Ok buttons till all the dialogs close
3. Go to Tool>Rules and Alerts
4. Create a new Rule. Select "Move messages with specific words in the Subject to a folder".
5. Tick the With Specific Words in the message header checkbox. In the Subject field, add "Recall:". In the header field, add "iso-8859-1"
6. Click Next, Tick the "Stop Processing more rules" checkbox. Set the "specified folder" to Deleted Items
7. Click Next, Next, Finish

At the end of it, the rule should look like this:
Rule Screenshot

That's it, recall will no longer work in your Oulook, even if the administrator allows it and the original sender tries it. The Recall message will end up in the deleted items folder and even if you double click it, will only send a failure message to the original sender.

Wave evaluation: Still not ready for big time! No numbered lists (WTF), no "publish" option, doesn't work in IE6, I am not sure if Google indexes it - overall, useless! Also, the embed JS doesn't work Out Of the Box with Blogger - Blogger keeps inserting <br/>
tags for returns, so I had to convert it to a single line JS!

Original Post Below

I was trying out embedding a Wave in my blog. It really sucks! If you are lucky, you should see the Wave below. If not, Google Wave Sucks! Try this link instead.