LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rsync question (https://www.linuxquestions.org/questions/linux-newbie-8/rsync-question-4175538957/)

willc86 04-06-2015 08:24 PM

rsync question
 
Hey guys, I have rsync going to another remote server
it works good, however, lets say server A deleted a directory, server B wont sync up to it.

if I were to add a directory to Server A, then server B will add it as well. so server B is just not deleting stuff.

is there a proper rsync command i can use ?

would rsync -xzva --delete /src /dst delete everything and start the rsync from scratch? or is there another way to do this

rknichols 04-06-2015 09:10 PM

Quote:

Originally Posted by willc86 (Post 5343593)
would rsync -xzva --delete /src /dst delete everything and start the rsync from scratch? or is there another way to do this

It would sync /src to /dst/src, first by deleting from /dst/src anything that did not exist in the single filesystem under /src. Then it would transfer any new or changed files in the single filesystem under /src to a tree under /dst/src.

You probably wanted
Code:

rsync -xzva --delete /src/ /dst
                        ^

to transfer the contents of /src to /dst rather than to a directory /dst/src.

If there are any hard linked or sparse files under /src, you should take a look at the "-H" and "-S" options.

willc86 04-08-2015 07:06 PM

Thank you for the reply!

I understand /src vs /src/ actually took me a while why rsync was doing that ha ha!
anyhow, so --delete would delete the stuff that did not exist from /src, but not the entire content, correct?
reason I ask is because I rsync 100 gigs and it would take way too long for it to back up

rknichols 04-08-2015 07:37 PM

It will delete only the files that do not exist in the source. There are several variants of "--delete", such as "--delete before", "--delete during", and "--delete after". You really should read the rsync manpage and understand when some of those might be more appropriate.

You can always run rsync with the "-n" and "-v" options to safely see exactly what it is going to do and when.

willc86 04-09-2015 11:15 AM

ya that is what i thought...however it is not working for me.
this is what I am using

#!/bin/bash
rsync -zavh --delete /files root@server.com:/backup/daily

my cron job is set to * * * * script.sh so i can test it every min

when I run the su -s * command, i see it is always deleting everything inside and starting the rsync over.
so that is the part I am trying to figure out.

i even let the rsync finish then ran
rsync -zavh --delete /files root@server.com:/backup/daily again and deleted everything all over and starts
the rsync from start

suicidaleggroll 04-09-2015 11:58 AM

Quote:

Originally Posted by willc86 (Post 5344966)
when I run the su -s * command, i see it is always deleting everything inside and starting the rsync over.
so that is the part I am trying to figure out.

"su -s *"? What is that supposed to do?

What are your source and destination filesystems?

rknichols 04-09-2015 12:11 PM

Perhaps some issue with the "root@" where the remote rsync user is different from the local user. I don't know. I've never used rsync that way. You could try including the "-i" (--itemize-changes) option and get some idea from what rsync believed had to be changed.

Habitual 04-09-2015 12:22 PM

Quote:

Originally Posted by willc86 (Post 5344966)
rsync -zavh --delete /files root@server.com:/backup/daily

I've always stuck the --delete after the target, eg:
Code:

rsync -zavh /files root@server.com:/backup/daily --delete
and never had any issue with it deleting files on the target not present in the src.


All times are GMT -5. The time now is 05:47 AM.