Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-14-2011, 10:23 AM   #1
Russell P
LQ Newbie
Registered: Jul 2011
Posts: 2

Rep: Reputation: Disabled
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
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?

- Russell
Old 07-14-2011, 10:59 AM   #2
John VV
LQ Muse
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,041

Rep: Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458Reputation: 2458
read the man page
man rsync
/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
Old 07-14-2011, 11:07 AM   #3
Russell P
LQ Newbie
Registered: Jul 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
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.

Last edited by Russell P; 07-14-2011 at 11:20 AM.


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
[SOLVED] Files seem to take up more space in destination after rsync copy Karderio Linux - Newbie 6 09-22-2014 07:41 PM
[SOLVED] Deleting all files from a directory except for two nonshatter Linux - Newbie 2 11-25-2010 08:57 AM
What parameter do I add to RSYNC to update modified or new files to the destination? tankman1989 Linux - Software 2 02-20-2010 06:20 PM
Changing permissions of destination directory after rsync cliff123 Linux - General 1 12-26-2007 03:09 AM
how to remove a symlink without deleting the destination directory Snerkel Linux - Software 3 01-20-2005 11:47 AM

All times are GMT -5. The time now is 10:32 PM.

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