MacOS – Copy to network share using local disk cache in Mac OS X Lion

backupcommand linemacos

I'm using rsync in Mac OS X Lion to copy a backup directory from my local HD to a network mounted share (local LAN). My goal is to archive the local backup to the network drive, thereby freeing up local disk space.

The rsync command I am using is:

rsync -aPW * /Volumes/netshare/path

For some reason, my free disk space is decreasing as rsync runs, and I eventually run out of space. After killing the rsync process and waiting, the consumed disk space is eventually freed and returns as free space.

It seems as if the copied files are being cached locally (even though they're already on the local drive) prior to being copied by rsync. I've checked and it's not swap space, and I have 1.5 GB of free RAM as rsync is running.

Has anyone else noticed this and is there a way to disable this caching in rsync?

Update:

I've tested with rsync, cp, and copying a file in Finder, and free disk space decreases in all 3 scenarios, so it's a general OS issue. I've been using lsof to see which files rsync has open, and nothing there appears to be growing in size. My theory has been that the files are being cached somewhere on the drive as the copy progresses. I have > 2GB RAM free and 0 swap space being used, so it doesn't appear to be a virtual memory usage issue.

As I mention below, disabling local snapshots also had no effect on the growing disk space.

Best Answer

My first guess would be that you got a typo in the target path (/Volumes/netshare/path, especially the netshare part) and are actually duplicating the data onto the source drive.

If not, I don't really see the benefit of using rsyncfor a one-off copy operation with limited risk of interruption -> just use cp instead, OSX takes care of the network part anyway if you copy something to a share mounted under /Volumes.

If you absolutely want to use rsync leave off the -PW options for a starter. -W is used anyway unless you sync directly to another server by specifying the target as remotehost:path/to/dir, -P is only needed if the sync runs the risk of getting interrupted.