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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-06-2011, 08:40 PM
|
#1
|
Member
Registered: Jul 2003
Location: Grand Meadow MN
Distribution: Mandrake 2010.2 & Fedora 14
Posts: 99
Rep:
|
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
|
|
|
04-06-2011, 09:07 PM
|
#2
|
Senior Member
Registered: Aug 2009
Posts: 3,790
|
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
|
|
|
04-06-2011, 09:29 PM
|
#3
|
Member
Registered: Jul 2003
Location: Grand Meadow MN
Distribution: Mandrake 2010.2 & Fedora 14
Posts: 99
Original Poster
Rep:
|
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.
|
|
|
08-10-2015, 03:52 PM
|
#4
|
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,534
Rep:
|
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.
|
|
|
08-10-2015, 05:20 PM
|
#5
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,797
|
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.
|
08-10-2015, 05:32 PM
|
#6
|
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,534
Rep:
|
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?
|
|
|
08-10-2015, 06:05 PM
|
#7
|
Member
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852
|
Not sure if that's what you're talking about, but the trailing slash after source does matter.
|
|
1 members found this post helpful.
|
08-10-2015, 08:07 PM
|
#8
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,797
|
Quote:
Originally Posted by millgates
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.
|
08-10-2015, 11:08 PM
|
#9
|
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,534
Rep:
|
Ah, the trailing slash, without the wildcard, works fine. Thank you.
I can't mark this thread as solved. it isn't mine.
|
|
|
All times are GMT -5. The time now is 01:45 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|