I'd like to access my Time Machine backup files using a little bash script. As I understand it, this requires a two-step process.
First, I have to mount the Time Capsule "Data" partition:
mount_afp afp://user:pass@10.0.1.1/Data ~/Data
Then, I have to mount the .sparsebundle on the Data partition that contains the backup files of my Mac. I'm not sure how to do this.
It also seems rather awkward that I have to do two mounts to access my backup files. Perhaps I can do it in one step?
I'd love to hear the best solution for this.
Best Answer
If you've configured a regular Time Machine backup onto your Time Capsule, mounting (or unmounting) the sparsebundle is not needed. It's already mounted or you wouldn't be able to backup your data regularly.
To mount the remote Time Machine sparsebundle and get the path to it simply enter:
(or
tmutil latestbackup > /dev/null 2>&1
if you don't want any output)The command triggers the mounting of the sparsebundle and the output is the path to your last backup.
Entering
mount
will show you the mount points of the Time Capsule and your sparsebundle.Your result will be something like (example listing):
The second last line is the Time Capsule share, the last line (disk2s2) the mounted sparsebundle image. The mounted share/sparsebundle aren't visible in the Finder because they are flagged as nobrowse.
To access your backup you can simply enter something like:
(All terms framed by percent signs depend on your environment and you have to replace them by proper names/addresses - get them by diving into the folders with
cd
andls -la
.)