Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

Anyone know why:

rsync -azuv --exclude "*.db" --delete /etc/postfix/ /home/backups/system/etc/postfix/

Would delete files from the destination that don't exist on the source (as it is supposed to), but:

rsync -azuv --exclude "*.db" --delete /etc/postfix/* /home/backups/system/etc/postfix/

Doesn't?

There is nothing "funky" about the files (as far as I can tell) that don't get delete by the second command - in other words, they don't start with a "." or anything. For the record (not that it matters) the files that weren't removed from the destination after I deleted them from the source were:

postgrey_whitelist_recipients.rpmnew postgrey_whitelist_clients.rpmnew postgrey_whitelist_clients.local.rpmnew

TIA!

asked 04 May '10, 04:17

Acorp's gravatar image

Acorp
312
accept rate: 0%

edited 06 May '10, 17:11

daniel.hahler.de's gravatar image

daniel.hahle...
12




From the man page:

--delete delete extraneous files from dest dirs

As we can see, it expects you to pass the directory containing the files (/path/to/directory/) - not the files themselves (/path/to/directory/*).

link

answered 04 May '10, 04:28

feinom's gravatar image

feinom
2195
accept rate: 33%

Thanks, that makes sense. So, a corollary question:

I have the following files in my source directory: 1.one 1.two 1.three 2.one 2.two 2.three

I only want to back up *.one files, so I run the following rsync command:

rsync -azuv --delete source/*.one dest/

Perfect, I get 1.one, 2.one, and 3.one in the dest.

But say 1.one gets deleted from my source directory. When my rsync command is run again, it doesn't delete 1.one from dest.

Without creating complex --include-from --exclude-from, is there a way to make rsync do what one would expect in this situation using wildcards?

(04 May '10, 05:14) Acorp

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.

This means you can't use source/*, because it contains a wildcard. Check out the --files-from=FILE switch in rsync's manual. This allows you to create a file containing a list of the files you want to copy.

(09 May '10, 16:49) feinom

--delete does not appear to take any arguments: it's just a switch!

However, using "/etc/postfix/*" on the shell (without the quotes) will get expanded (by the shell) to all files in /etc/postfix, therefore you're basically passing a list of existing source files (and not a directory to "compare").

You want to just pass the directory only.

link

answered 06 May '10, 17:10

daniel.hahler.de's gravatar image

daniel.hahle...
12
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×3
×1

Asked: 04 May '10, 04:17

Seen: 4,233 times

Last updated: 06 May '10, 17:11

powered by OSQA