LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-06-2010, 02:30 AM   #1
ssisbi
LQ Newbie
 
Registered: Jan 2010
Posts: 13

Rep: Reputation: 0
rsync example? (newbie)


my system is running rsync version 3.0.7. i want to use it to synchronize files and folders in another directory on the same system. however, i want to exclude particular files and/or folders when i execute the command. i'm not familiar with rsync and i'd like someone to please verify the syntax for me. below is an example of what i want to do:

rsync -vru --exclude=/path/to/source/files/dir1 --exclude=/path/to/source/files/dir2 --exclude=/path/to/source/files/dir3/filename1.ext --exclude=filename2.ext --dry-run /path/to/source/files /path/to/target/folder

would my example work (with and without the dry-run flag)?

thanks in advance...
 
Old 02-06-2010, 03:32 AM   #2
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
I'd rather not assume I know exactly what it is you want to do, but here are some tips:

1) The -a flag might be of use to you to make sure you sync pretty much everything.

2) The order of the --exclude's matters.

3) There is a difference between hiding something and excluding something. See the more general --filter option.

4) Use the -i flag so you can see exactly what is going on. I usually have a -in at the end of my rsync command. That way I can check what's happening first, then easily run the command again and remove the n so it can run for real.

5) If you want a true sync, you may want to look at the --delete flag. And to be safe, look into the --backup flag (to be used with --delete).

6) A trailing slash matters for the source directory! (It doesn't matter for the destination.)

Good luck!

Last edited by Meson; 02-06-2010 at 03:45 AM.
 
1 members found this post helpful.
Old 02-06-2010, 03:44 AM   #3
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Ok, so looking at your command, there is one thing that I'm sure you are confused about.

Your source is /path/to/source/files and, for example, your first exclude is /path/to/source/files/dir1. This is actually excluding /path/to/source/files/path/to/source/files/dir1. The filter rules are relative to the source. So what you want is one of the following:

1) --exclude=dir1 # this will exclude any file or directory named dir1, anywhere below /path/to/source/files

2) --exclude=dir1/ # this will exclude ONLY directories named dir1, anywhere below /path/to/source/files

3) --exclude=/dir1 # this will exclude TTHE file/directory dir1 if it exists at the root of your transfer, so /path/to/source/files/dir1, and only that

4) --exclude=/dir1/ # similar to the above, but only a directory
 
1 members found this post helpful.
Old 02-08-2010, 04:34 AM   #4
ssisbi
LQ Newbie
 
Registered: Jan 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Meson,

is there a difference between HIDE and EXCLUDE? if so, what is it?
 
Old 02-08-2010, 12:09 PM   #5
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
If you exclude a file/dir then it won't be transferred; it also won't be deleted if it exists on the destination but not source.

If you hide a file/dir, it's as if it doesn't exist. So if it is on the destination, and you use the --delete option, the file will be deleted.
 
Old 03-02-2010, 05:48 PM   #6
roeland.de.windt
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Question Order of exclude arguments

Quote:
Originally Posted by Meson View Post
2) The order of the --exclude's matters
Can you please elaborate? For my backups, I'm thinking about switching to an exclude *file* (high numbers of exclude arguments quickly become unwieldy in the --exclude= syntax).

Does order apply here too? I.e. Do I put "wildcards" (folders and/or files occuring anywhere) first or last in the list?

Thx.

Last edited by roeland.de.windt; 03-02-2010 at 05:50 PM. Reason: Cosmetics
 
Old 03-03-2010, 05:39 PM   #7
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
You have to play around with it. Use the "-n" flag for a dry run.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync solaris + ld.so.1: rsync: fatal: libiconv.so.2: open failed: xxx_anuj_xxx Solaris / OpenSolaris 25 02-23-2012 03:23 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM
rsync newbie --delete -b noir911 Linux - General 1 11-23-2006 12:21 AM
Windows Rsync Upload to Linux Rsync - permissions inspleak Linux - Software 0 10-12-2004 02:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration