rsync. The best way to copy files between servers.

rsync to copy multiple files via ssh to a remote machine. Same syntax as scp:

-a Archive mode (ensures that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer)

-v Increase verbosity

-z Use compression

–progress, to show progress

In this example all files in /root/temp on the host machine are copied to the remote machine.

Setting up an NFS share between a virtual Parallels Ubuntu server and OS X Mountain Lion

Parallels upto now has made my life very easy for virtualisation. Instances run fast, don’t slow down the mac and setting up shared directories so remote server and host can see the same application files works flawlessly. Until today that is…

Today I need to setup Symfony2. During it’s setup, config and running it uses a combination of cli and web tools which did not get on with my usual shared directory setup. I could either get it running on the mac without the ubuntu server able to see it or working on ubuntu without the IDE on the mac able to see it.

The solution turned out to be simple – NFS to the rescue!

On the mac to setup the NFS server edit the /etc/exports file to specify the directory to share and the network range that can see it. Most importantly is  -mapall=root:wheel which ensures that all client writes appear as root, so there are no permission hassles on the client end.

UPDATE: on using this method to share a system directory on another project the share failed, so it may not be possible to use this option in all cases.


At the client end create a mount point and mount:

And for good measure add into /etc/fstab

Export a mongo collection as csv

Started to create a script to do this, then realised mongoexport can do this out of the box!

Browse and delete records in mongodb

Copying a parallels linux instance to a new machine – and getting eth1 instead of eth0

Copying a parallels instance is easy as copying the file from one machine to another.

But, this seems to screw up networking. The copied instance starts but a call to ifconfig -a shows no eth0 but a disconnected eth1 instead.

I’m guessing this is because the mac address the new version of parallels is supplying is different.

A way to fix is to edit /etc/udev/rules.d/70-persistent-net.rules

and remove the old card definition, and reassign eth0 to the new card


In hindsight a better thing to try would be to set the mac address to that of the original machine before starting the instance on the new machine.

Removing ._ files created by Mac OS X

I moved some files to an Ubuntu server and found all files and directories had duplicate ._ versions. Apparently these are created for the OS X finder.

To get rid:

Script to restore all collections from mongodump

Feed this script the path to the dump directory created from mongodump to restore all collections. Handy to copy all mongo data to a new server.

trac report to list tickets by milestone with milestones ordered by due date

On my version of trac report 3 was great but ordered milestones alphabetically, rather than by due date.

The following trac sql fixes it: