Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've noticed some issues with rsync and .gvfs over the years. Typically I just --exclude=.gvfs in my rsync command and call it a day.

Recently I decided to read the rsync man page top to bottom left to right. After all, what better way to learn? Man pages are quicker than Googling, if you ask me. I had noticed the -x flag, which was cited to not cross other file systems. I began to wonder what exactly that meant and thought... would -x also ignore .gvfs, being a virtual file system?

That said, would:

rsync -a --exclude=.gvfs /home/jason /media/externalhdd

(be kind of the same as)

rsync -ax /home/jason /media/externalhdd

????

share|improve this question

1 Answer 1

Yes, it should be the same.

To check for sure: run stat on your two directories: /home/jason and /home/jason/.gvfs. The stat output will show a "device" entry:

[jk@pecola ~]$ stat $HOME
  File: `/home/jk'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 803h/2051d  Inode: 5242881     Links: 65
Access: (0755/drwxr-xr-x)  Uid: ( 1000/      jk)   Gid: ( 1000/      jk)
Access: 2012-03-19 11:53:31.209584100 +0800
Modify: 2012-03-19 11:50:42.941630852 +0800
Change: 2012-03-19 11:50:42.941630852 +0800
 Birth: -

-- it's the first item in the third line. The number is shown twice: in hex ('h' suffix), and in decimal ('d' suffix).

If these numbers are different between the two directories, they're considered to be on different device, so the -x option will prevent rsync from traversing to this directory.

share|improve this answer
    
Thanks for the info. I'll likely just leave the --exclude tag in there, but I was curious if -x by nature handled the very task I was accomplishing with --exclude=.gvfs. Now help me out here. I'm trying to understand what happens when you rsync .gvfs. Last I looked, in .gvfs were the contents of my backup server. Yet, I'm rsyncing to my backup server. So, rsyncing .gvfs to my backup server was duplicating my data, because I had my data there already, as well as in .gvfs that was synced. Am I correct in saying that it essentially duplicated, albeit in different locations on the backup server? –  JaSauders Mar 19 '12 at 4:01
    
That's correct; by rsyncing the contents of .gvfs, you're copying stuff that's already on the backup server to the backup server. Next time, you'll be copying the same stuff again, so you end up with three copies of the data, ad infinitum. –  Jeremy Kerr Mar 19 '12 at 5:23
    
Keep in mind that -x may be more reliable that --exclude=.gvfs, as the directory may move - my machine (a precise install) has it in ~/.cache/gvfs. –  Jeremy Kerr Mar 19 '12 at 5:26
    
Jeremy, thank you very much for clarifying this. What baffles me more is if this is the case, why is it in 99% of the cases when I hear other users talk about how to set up rsync that they don't include -x. More often than not, it's -azn at most. I think I'll be editing my scripts tonight to rsync -axn and call it a day. –  JaSauders Mar 19 '12 at 12:51
    
My apologies, I was typing a bit too carelessly. More times than not I'm seeing simply -av, not -azn. To summarize, if it's this easy to duplicate data, why aren't more examples to helping users out -avx instead of just -av? –  JaSauders Mar 19 '12 at 13:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.