LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-06-2011, 08:40 PM   #1
shea1roh
Member
 
Registered: Jul 2003
Location: Grand Meadow MN
Distribution: Mandrake 2010.2 & Fedora 14
Posts: 99

Rep: Reputation: 17
rsync --delete not working


I would like to use rsync to keep the hard drive in my media server synced with my video collection on my linux server. The media server I believe is running some version of linux running samba. I mount the media servers share to a folder on my linux server & use the following command:


rsync -a -vv --delete /home/shared/Videos/* /mnt/WDLive/Shearer\ Files/Movies/

However, it does not delete files on the media server that I delete on the source. I also created a new folder on the source & moved some of the files into it. When I ran rsync again, it created the new folder on the media server, but it recopied all the files from the source again, instead of moving the files which were already on the media server into the new folder, so no I have 2 copies. Any idea what I am doing wrong? Thanks
 
Old 04-06-2011, 09:07 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
rsync can only make the destination look like the source by adding or deleting files, in this case it looks like the delete is failing - are you seeing any messages regarding the deletion failing ? .. if you change the argument to '--delete-after' it may make the problem easier to find

cheers
 
Old 04-06-2011, 09:29 PM   #3
shea1roh
Member
 
Registered: Jul 2003
Location: Grand Meadow MN
Distribution: Mandrake 2010.2 & Fedora 14
Posts: 99

Original Poster
Rep: Reputation: 17
I changed '--delete' to '--delete-after' but the extra files on the target are still not being deleted. There are no error messages, or mention of the extra files on the target. I increased the verbosity but still no joy.
 
Old 08-10-2015, 03:52 PM   #4
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,534

Rep: Reputation: 112Reputation: 112
I am undigging this topic from the grave because it's not solved and I have the same problem now. My command line is:

# rsync -aSHxv --delete-before /source/* /mnt/target/

After much waiting and copying, the command exits with an error because it has run out of space on the target file system. But the two file systems are exactly the same size. It shouldn't run out of space.

Upon time consuming investigation, I find that rsync has indeed not deleted on the target FS two rather big directories that no longer exist on the source FS.

So it's upon me to waste time and delete them manually...

Then I run the same command line again and it completes, but 'df -h' reveals the available free space is considerably smaller on the target. Something is up, of course.

I use 'du -h | sort' and find three more directories that have not been deleted.

I delete them, I run the command line again, rsync reports no changes, but I still find a difference. I finally detect two files on the very root (not inside any directory) of the file system that should have been deleted.

I have everything logged with the 'script' command and I see that rsync does delete a lot of stale files and directories, but skips some, of which I can't identify anything particularly different from the rest.

What is wrong with my command line? Or is there something wrong with rsync?

Last edited by lucmove; 08-10-2015 at 03:57 PM.
 
Old 08-10-2015, 05:20 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,797

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
The argument "/source/*" will be expanded by the shell to a list of individual files and directories. rsync will see only that list and dutifully transfer all of the items that exist (which is all of them -- the shell took care of that) and delete from the destination anything in that list that does not exist in /source (which, of course, is nothing since the shell wouldn't include such a name in the expansion). Now if there are subdirectories in /source, rsync will recurse into those directories, compare what it finds at the source with what it finds at the destination, and delete from the destination anything that does not exist at the source. That can work only when rsync itself is recursing into a directory, not when you've given it a list of names (all of which exist) generated by the shell.

Just leave off the "*" from the end of the source argument, and rsync will do what you want.

Last edited by rknichols; 08-10-2015 at 05:21 PM.
 
1 members found this post helpful.
Old 08-10-2015, 05:32 PM   #6
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,534

Rep: Reputation: 112Reputation: 112
Can you suggest another command line then?

The problem with simply removing * is,

hard disk:
/home/luc/source

external disk:
/mnt/target

command line:
# rsync -aSHxv --delete-before /home/luc/source /mnt/target/

result:
target will preserve everything inside it and add the 'source' directory, containing duplicates of a megaton of data it already contains at the root of the file system.

OK, I can move everything in target into a 'source' directory, then it will work, but for the sake of enlightenment, what if I adamantly want to keep everything at the root?
 
Old 08-10-2015, 06:05 PM   #7
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Not sure if that's what you're talking about, but the trailing slash after source does matter.
 
1 members found this post helpful.
Old 08-10-2015, 08:07 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,797

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by millgates View Post
Not sure if that's what you're talking about, but the trailing slash after source does matter.
Exactly! The trailing slash says to copy the contents of the directory, not the directory itself, to the destination. I said to remove just the trailing "*", not the slash.
 
1 members found this post helpful.
Old 08-10-2015, 11:08 PM   #9
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,534

Rep: Reputation: 112Reputation: 112
Ah, the trailing slash, without the wildcard, works fine. Thank you.

I can't mark this thread as solved. it isn't mine.
 
  


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
cron: rsync /var...--delete? erics_acvw Linux - Software 3 02-14-2010 06:25 PM
rsync (cygwin on XP) - -delete flag not working. bobby953 Linux - Newbie 1 08-05-2009 11:13 AM
rsync doesn't seem to delete cooks44 Linux - Software 10 11-22-2007 12:57 AM
rsync newbie --delete -b noir911 Linux - General 1 11-23-2006 01:21 AM
rsync --delete question Red Squirrel Linux - Software 2 10-10-2005 10:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:45 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