Carry my network content on a portable challenge...

ZaphodB

macrumors newbie
Original poster
Aug 15, 2012
6
0
So here's the challenge:

How would you take selected data from a network-volume onto a portable drive on a road?

In other words: how would you do the following:
1) Copy content from NAS to a portable. (that's easy)
2) Disconnect my Macbook from the network. (ever easier)
3) Plug this portable to Macbook and... would my Mac be fooled? Or I should ask: how would I fool it to see it as "/volumes/share/"?

Maybe mounting (obviously one at a time) disks or volumes forcibly to the same path (i.e. mount-point) using the terminal?

Any changes to the files on the portable while on the road I would like to synchronize with the NAS eventually, but that's the next level...
 
Last edited:

ZaphodB

macrumors newbie
Original poster
Aug 15, 2012
6
0
Idea to solve it...

After doing some research this is what I came up with:

Using the network online scenario:
----------------------------------------
1) Create custom mount-point (e.g. a folder "share_point")
2) Mount my network share (e.g. "myshare") into that mount-point

Using the portable scenario
----------------------------------------
1) Create disk image (e.g. "myshare_offline") containing selected network folders (e.g. "myshare/iTunesLib/") from the network share
2) Disconnect from the network.
3) Mount the disk-image into the custom "share_point" folder.


Example:

Network online scenario
----------------------------------------
mkdir /Volumes/share_point
mount -t smbfs //userid:password@192.168.0.999/myshare /Volumes/share_point

Offline scenario
----------------------------------------
hdiutil attach myshare_offline.dmg -mountpoint /Volumes/share_point

I've tested the examples and it appears to be working. Just wondering if anybody can see any flaws in my logic? Possible improvements? And finally any good tips on synchronizing disk-image with network drives?
 

gentlefury

macrumors 68030
Jul 21, 2011
2,848
0
Los Angeles, CA
After doing some research this is what I came up with:

Using the network online scenario:
----------------------------------------
1) Create custom mount-point (e.g. a folder "share_point")
2) Mount my network share (e.g. "myshare") into that mount-point

Using the portable scenario
----------------------------------------
1) Create disk image (e.g. "myshare_offline") containing selected network folders (e.g. "myshare/iTunesLib/") from the network share
2) Disconnect from the network.
3) Mount the disk-image into the custom "share_point" folder.


Example:

Network online scenario
----------------------------------------
mkdir /Volumes/share_point
mount -t smbfs //userid:password@192.168.0.999/myshare /Volumes/share_point

Offline scenario
----------------------------------------
hdiutil attach myshare_offline.dmg -mountpoint /Volumes/share_point

I've tested the examples and it appears to be working. Just wondering if anybody can see any flaws in my logic? Possible improvements? And finally any good tips on synchronizing disk-image with network drives?
You could also go a step further and create a bash script that runs whenever you start your computer and basically create a conditional to drive the switch...something like this:

if [[ -f /Volumes/offline_disk/myshare_offline.dmg && ! -d /Volumes/myshare ]]
then
hdiutil attach myshare_offline.dmg -mountpoint /Volumes/share_point
return
elif [[ ! -f /Volumes/offline_disk/myshare_offline.dmg && -d /Volumes/myshare ]]
then
mkdir /Volumes/share_point
mount -t smbfs //userid:password@192.168.0.999/myshare /Volumes/share_point
return
elif [[ ! -d /Volumes/myshare/ && ! -f /Volumes/offline_disk/myshare_offline.dmg ]]
then
.
return
elif [[ -f /Volumes/offline_disk/myshare_offline.dmg && -d /Volumes/myshare/ ]]
then
hdiutil attach myshare_offline.dmg -mountpoint /Volumes/share_point_offline
mkdir /Volumes/share_point_online
mount -t smbfs //userid:password@192.168.0.999/myshare /Volumes/share_point_online
rsync -va /Volumes/share_point_online /Volumes/share_point_offline
return
fi
change the values that you need to change and set it as a startup item and whenever you start your computer it will check if the offline disk is there and mount it accordingly...to explain what its doing, if you don't know bash, it is checking to see if the offline volume exists...if it does, then it mounts it. If the online volume exists and the offline doesn't it will mount the online disk...if the offline exists and the online doesn't it will mount that one. If neither exists it won't do anything. If both exist it mounts them to an offline and online mountpoint and syncs the data from the online to the offline automatically.
 
Last edited:

gentlefury

macrumors 68030
Jul 21, 2011
2,848
0
Los Angeles, CA
I'm not sure what your comfort or knowledge level with with scripting, but to make an executable file out of this code you would just copy it to text editor and save the file with no extension, so something like :

offlinesync

then go into terminal and navigate to the location of the file, and type chmod +x offlinesync.

that will make it executable...you can double click to run it, or, what I would recommend is to put it in your user profile as a startup item and hide it so it won't run in the foreground.

That way it will automatically work when you restart or login.

for the sync action both drives must be present tho...so you would probably want to run it so they sync, then unplug the external drive and run it again to re-set the volume.
 
Last edited:

ZaphodB

macrumors newbie
Original poster
Aug 15, 2012
6
0
Thank you gentlefury. Your approach would definitely make the whole process hands off (I'm surprised we don't have a comercial tool out there for this), and I'm sure that many people would benefit from an offline-folder setup. Well, aside from Dropbox (duh!).

I'm experimenting with the scripts. They do mount the network share or my disk image to the same mount-point. Simple programs get fooled, but iTunes doesn't. It doesn't "see" its network library when switching to the offline-config. Once I point to it manually, it seems okay. I'm suspecting this is related to drives using unique UUIDs (or something to that affect, I could be wrong) not the actual path.
 
Last edited: