Backing Up My Books

I have a lot of eBooks on my tablet and phone. I also have a backup on my Linux laptop. In the past I have often just plugged the tablet into the laptop, opened the appropriate MTP folder, selected everything and copied them all to the backup, overwriting the previous backup. There has to be a better way, surely? Step up rsync.

The problem is the MTP mount, however, I found a way to make it work. Those mounts, mainly from Android devices, usually open the the appropriate file explorer application in the laptop. But, they are mounted — somewhere — and with a bit of digging, we can find the mount point, and from that, run rsync to do the backup of the files that are new or updated only.

Finding the Mount Point

The first problem, is where on earth has the Android device been mounted?

$ gio mount -li | grep -i activation_root |\
  cut --delimiter== --fields=2 |\
  cut --delimiter="/" --fields=3


So, that’s the mount point sorted. Well, part of it. I need to know where it’s mounted. This turned out to be:


where 1000 is my user id. That colon will need escaping too, I suspect! Now, how to work that out in code in case it ever changes?

Finding my User Id

This is easy enough, the file /etc/passwd holds details of my user id in the third field, fields are separated by colons, so, cut to the rescue!

$ grep ^$USER /etc/passwd |\
  cut --delimiter=: --fields=3


That was simple. So, this should work then? I’m using the short form of the cut parameters here by the way. Less typing! I’m also using the $(...) form of extracting a result from a command, WordPress has stopped me using backticks for some reason!

$ ## Where the backups live.
$ cd ~/Backups/Tablet/

$ ## Get my user id,
$ USER_ID=$(grep ^$USER /etc/passwd | cut -d: -f3)

$ ## Get the MTP mounted device.
$ DEVICE=$(gio mount -li | grep -i activation_root |  cut -d= -f2 | cut -d/ -f3)

$ ## Get the actual mount point for the MTP device.
$ MOUNT=/run/user/${USER_ID}/gvfs/mtp\:host\=${DEVICE}/Tablet/My_Books

$ ## Run the backup from MTP to Backups/Tablet/My_Books/
$ ## Trailing slash on "$MOUNT" is important here.
$ rsync $MOUNT/ --archive --recursive --verbose My_Books/

And, indeed it does. I did have a problem though. My_Books used to be named My Books. Neither the ls command, nor rsync could see it on an MTP mount point, for some unknown reason. The file manager could, and allowed manual copying. However, a quick rename and all was well.

So, now I’ve built the above into a shell script and saved it in $HOME/bin/ for future use.

Arduino Internal Temperature Measuring

The code below, somewhere, shows how to measure the temperature of the ATmega328 microcontroller built in to numerous Arduino boards. You can find all the gory details in my new book Arduino Software Internals available from Apress, Amazon and good bookshops everywhere.

A complete guide to how the Arduino Language works, and how it makes the hardware work.

Continue reading Arduino Internal Temperature Measuring

Build 64bit OCILIB Libraries for CodeBlocks

I tend to compile with gcc, in a bash session, on Windows 7. I use Code::Blocks as my IDE of choice and one of my projects, well, quite a few, use the excellent OCILIB library for accessing Oracle databases, by Vincent Rogier. I can’t recommend this library highly enough.

However, it comes with a Code::Blocks project file to build 32 bit libraries, but I need 64 bits. Here’s how I do it.

Continue reading Build 64bit OCILIB Libraries for CodeBlocks

Useful AIX Unix Commands


The proctree command acts like the Linux pstree and displays the hierarchy of processes from a given starting process id.

View Large Files

If, when you view a large file you get an errors about it being too big, try the following:

echo "set ll=3501720 dir=/tmp" >> ~/.exrc

That will allow you to read up to 3501720 lines in a single text file.

Generate Entity Relationship Diagrams from a SQL Script.

Sometimes, just occasionally, you find yourself as a DBA on a site where, for some strange and unknown reason, you don’t have an Entity Relationship Diagram (ERD) for the database that you are working on. You could use a tool such as Toad, or SQL*Plus (or even, SQL Developer – if you must) to generate a list of referential integrity constraints. There has to be a better way. Continue reading Generate Entity Relationship Diagrams from a SQL Script.

Snorkelling in the Oracle Listener Logs.

(Snorkelling is not quite as in depth as a “deep dive”!)

Attempting to parse a listener.log will probably bend your brain, but I needed to do it recently to determine which unique servers and/or desktops and/or application servers were still connecting to a database prior to that database going down for maintenance. This was an exercise in confirming that the documentation we have, is correct.

Continue reading Snorkelling in the Oracle Listener Logs.

Arduino Nano – Cannot Upload Sketches after Board Upgrade to 1.6.21

My Arduino Nano started to refuse to upload sketches after I upgraded the boards library to version 1.6.21 from 1.6.20. All I got was this:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

Repeat 100 times!

After reverting back to the previous boards library, version 1.6.20, everything worked. I upgraded and everything stopped working.

The solution, from the forums, is simple:

Tools -> Processor -> ATmega328P (Old Bootloader)

Read the forum thread at if you wish. I’m just noting this here for my own reference and definitely not claiming any credit.

Using FUSE to Mount an SSH Folder Locally

I have recently come across a pretty nifty Linux utility that allows me to mount a remote filesystem on an SSH server, locally and without requiring root privileges to do so. The remote filesystem happens to be where my backups are located, so that’s going to be useful for making and restoring backups! Continue reading Using FUSE to Mount an SSH Folder Locally

FLAC to MP3 as Easy as Pie!

I have ripped all my music, well most of it, to FLAC for the quality aspect. Sometimes though, I need to convert to MP3 for some of the lesser audio players out there that I might have to use from time to time.

I have recently come across a pretty nifty (Linux) way to do this, without having to cope with having duplicate files in FLAC and MP3 formats on my hard drives. Continue reading FLAC to MP3 as Easy as Pie!