LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-29-2013, 03:08 AM   #1
boby.kumar
Member
 
Registered: Mar 2013
Posts: 92

Rep: Reputation: Disabled
rsync not deleting the destinations while using /* wild card in linux


Hi Team

I have a rsync on going for below two remote dir.

rsync -avg --delete /home/abc/* Host@Server:/home/jasmine/foo/

its not deleting the files or dir at receiving end if not exists at sending side.

while using without * its working properly like for

rsync -avg --delete /home/abc/ Host@Server:/home/jasmine/foo/


can anyone have any idea how to use --delete option with wild card for the same. i am totally stucked here.

Thanks in Advance
 
Old 11-29-2013, 03:24 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
To my knowledge you cannot use --delete and wild-cards together, this from the rsync manual page:
Quote:
This tells rsync to delete extraneous files from the receiving
side (ones that arenít on the sending side), but only for the
directories that are being synchronized. You must have asked
rsync to send the whole directory (e.g. "dir" or "dir/") without
using a wildcard for the directoryís contents (e.g. "dir/*")

since the wildcard is expanded by the shell and rsync thus gets
a request to transfer individual files, not the filesí parent
directory.
 
Old 11-29-2013, 04:12 AM   #3
boby.kumar
Member
 
Registered: Mar 2013
Posts: 92

Original Poster
Rep: Reputation: Disabled
thanks.

How will be this if I use --delete-excluded for the same. I have no option without wild card for rsync.

Is another way for this?
 
Old 11-29-2013, 04:26 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Without knowing exactly what it is you are trying to accomplish it is rather hard to help you.

If I look at your first post I wonder why you need to use the wildcard, why not use the example that works?
Code:
rsync -avg --delete /home/abc/ Host@Server:/home/jasmine/foo/
If wanted/needed you can add --exclude somedir/* --delete-excluded

Maybe this will help (examples and explanations):
- What exactly will --delete-excluded do for rsync?
- rsync
 
Old 11-29-2013, 04:53 AM   #5
boby.kumar
Member
 
Registered: Mar 2013
Posts: 92

Original Poster
Rep: Reputation: Disabled
yes. The actually point is rsync to different destination from the same source like this..

[rsync -avg --delete /home/abc/QW2* Host@Server:/home/jasmine/foo/

rsync -avg --delete /home/abc/PM* Host@Server:/home/jasmine/ZOO/
.
.
.
.

rsync -avg --delete /home/abc/PL123* Host@Server:/home/jasmine/foo12/


Actually /home/abc have the different dir and files. so i need to copy individually rather than whole dir.

Is the idea clear? so i am using wild card(*) for the same.

Thanks again.
 
Old 11-29-2013, 05:11 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Quote:
Originally Posted by boby.kumar View Post
yes. The actually point is rsync to different destination from the same source like this..
rsync -avg --delete /home/abc/QW2* Host@Server:/home/jasmine/foo/
rsync -avg --delete /home/abc/PM* Host@Server:/home/jasmine/ZOO/
rsync -avg --delete /home/abc/PL123* Host@Server:/home/jasmine/foo12/

Actually /home/abc have the different dir and files. so i need to copy individually rather than whole dir.

Is the idea clear? so i am using wild card(*) for the same.
It is not clear if QW2* / PM* / PL123* are files or directories.

Assuming they are directories, give this a try:
Code:
rsync -avg --delete /home/abc/QW2*/ Host@Server:/home/jasmine/foo/
Mind the slash....
 
Old 11-29-2013, 07:45 AM   #7
boby.kumar
Member
 
Registered: Mar 2013
Posts: 92

Original Poster
Rep: Reputation: Disabled
Thanks a lot druuna.

Its working but not our expectations as we were looking. Its coping only directory content without directory name.

Generally it should be for us with directory+content for the same time as rsync going
 
Old 11-29-2013, 09:51 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
I had time to test this and this is the result:

Directories (and content) that need to be rsync-ed: /home/druuna/Foo and /home/druuna/FooBar

Content of those directories:
Code:
$ ls -l Foo/ Foo/Foo2/ FooBar/
Foo/:
total 4
drwxr-x--- 2 druuna druuna 4096 nov 29 15:43 Foo2
-rw-r----- 1 druuna druuna    0 nov 29 15:43 foo.1
-rw-r----- 1 druuna druuna    0 nov 29 15:34 foo.2
-rw-r----- 1 druuna druuna    0 nov 29 15:34 foo.3

Foo/Foo2/:
total 0
-rw-r----- 1 druuna druuna 0 nov 29 15:43 foo2.1
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foo2.2
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foo2.3

FooBar/:
total 0
-rw-r----- 1 druuna druuna 0 nov 29 15:44 foobar.1
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foobar.2
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foobar.3
Content of /data/General/Target/ before syncing:
Code:
$ ls -l /data/General/Target/
total 0
Running rsync:
Code:
$ rsync -avg --delete /home/druuna/Fo* /data/General/Target/
sending incremental file list
Foo/
Foo/foo.1
Foo/foo.2
Foo/foo.3
Foo/Foo2/
Foo/Foo2/foo2.1
Foo/Foo2/foo2.2
Foo/Foo2/foo2.3
FooBar/
FooBar/foobar.1
FooBar/foobar.2
FooBar/foobar.3

sent 585 bytes  received 195 bytes  1560.00 bytes/sec
total size is 0  speedup is 0.00
Content of /data/General/Target/ after syncing:
Code:
$ ls -l /data/General/Target/* /data/General/Target/Foo/Foo2/
/data/General/Target/Foo:
total 4
drwxr-x--- 2 druuna druuna 4096 nov 29 15:43 Foo2
-rw-r----- 1 druuna druuna    0 nov 29 15:43 foo.1
-rw-r----- 1 druuna druuna    0 nov 29 15:34 foo.2
-rw-r----- 1 druuna druuna    0 nov 29 15:34 foo.3

/data/General/Target/Foo/Foo2/:
total 0
-rw-r----- 1 druuna druuna 0 nov 29 15:43 foo2.1
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foo2.2
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foo2.3

/data/General/Target/FooBar:
total 0
-rw-r----- 1 druuna druuna 0 nov 29 15:44 foobar.1
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foobar.2
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foobar.3
Remove Foo/foo.1, Foo/Foo2/foo2.1 and FooBar/foobar.1 and sync again:
Code:
$ rm Foo/foo.1 Foo/Foo2/foo2.1 FooBar/foobar.1
$ rsync -avg --delete /home/druuna/Fo* /data/General/Target/
sending incremental file list
Foo/
deleting Foo/foo.1
Foo/Foo2/
deleting Foo/Foo2/foo2.1
FooBar/
deleting FooBar/foobar.1

sent 185 bytes  received 24 bytes  418.00 bytes/sec
total size is 0  speedup is 0.00
Content of /data/General/Target/ after syncing:
Code:
$ ls -l /data/General/Target/* /data/General/Target/Foo/Foo2/
/data/General/Target/Foo:
total 4
drwxr-x--- 2 druuna druuna 4096 nov 29 15:49 Foo2
-rw-r----- 1 druuna druuna    0 nov 29 15:34 foo.2
-rw-r----- 1 druuna druuna    0 nov 29 15:34 foo.3

/data/General/Target/Foo/Foo2/:
total 0
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foo2.2
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foo2.3

/data/General/Target/FooBar:
total 0
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foobar.2
-rw-r----- 1 druuna druuna 0 nov 29 15:34 foobar.3
Works like a charm....

Last edited by druuna; 11-29-2013 at 09:53 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync not deleting the destinations boby.kumar Linux - Newbie 1 11-14-2013 05:55 AM
[SOLVED] Problem Using Wild Card With ls OtagoHarbour Linux - Newbie 14 02-23-2013 10:09 AM
Bash Wild Card rivacom Linux - General 15 08-05-2010 08:13 AM
Rsync keeps deleting another dir subzero80 Linux - Software 8 01-15-2008 04:14 PM
rsync not deleting bwilliam79 Linux - Software 1 10-04-2004 06:22 PM


All times are GMT -5. The time now is 08:54 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration