LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Rsync deleting files from destination directory (http://www.linuxquestions.org/questions/linux-newbie-8/rsync-deleting-files-from-destination-directory-891729/)

Russell P 07-14-2011 10:23 AM

Rsync deleting files from destination directory
 
Hi all, I'm new here so I'm sorry if I posted this in the wrong place, but I was hoping someone might be able to help me out with this problem we've been having with rsync.

We have an rsync cron job set up to mirror all the files in a "..\das\htdocs\docs" folder to the same folder on another server. It copies all the files over correctly and deletes any files in the "docs" directory that aren't in the sending directory, but it also deletes any files we put in the target directory's parent folder (..\das\htdocs\ or other subfolders like ..\das\htdocs\images) even though they've been excluded in the .rsync-filter file.

Here's our current rsync .sh:
/usr/local/bin/rsync --stats -qPzrtpl --delete --password-file=/var/run/.appprodrsync --log-file=/export/home
/webuser/logs/rsync-extranet-log -FF /export/home/ appprodrsync@appprod::dprweb_extranet/ > /export/home/webuser/logs/rsync-extranet-output 2>&1

Here's the filter rules we're using:
+ /das
+ /em
+ /enf
- /*

+ /*/htdocs
- /*/*

+ /*/htdocs/docs
- /*/htdocs/*

So for example server A has ..\das\htdocs\docs and ..\das\htdocs\images. Server B has ..\das\htdocs\docs but if I manually copy the images folder over to ..\das\htdocs\images, the images folder gets deleted from the target directory every time rsync runs.

A: ..\das\htdocs\docs
..\das\htdocs\images
B: ..\das\htdocs\docs\
..\das\htdocs\images (<-- gets deleted everytime rsync runs)

I'd like to keep just the docs directory synched and update other folders manually, but they keep getting deleted. It looks to me like it's running a delete-excluded option, but that option wasn't used.

Any idea what I'm doing wrong and how I can fix it?

Thanks
- Russell

John VV 07-14-2011 10:59 AM

read the man page
Code:

man rsync
Quote:

/usr/local/bin/rsync --stats -qPzrtpl --delete --password-file=/var/run/.appprodrsync --log-file=/export/home
you are USING the delete option in your command so yes it will delete the old files

Russell P 07-14-2011 11:07 AM

I did read the man page. But it's deleting files that are excluded. My understanding was that if a directory was excluded it would not delete those files unless the delete-exclude option was used.

EDIT: Specifically the --delete option is used to keep extraneous files out of the "docs" directory, not delete files and folders outside the docs directory.


All times are GMT -5. The time now is 01:20 AM.