LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-06-2015, 09:24 PM   #1
willc86
Member
 
Registered: Dec 2014
Posts: 54

Rep: Reputation: Disabled
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
 
Old 04-06-2015, 10:10 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
Quote:
Originally Posted by willc86 View Post
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.
 
Old 04-08-2015, 08:06 PM   #3
willc86
Member
 
Registered: Dec 2014
Posts: 54

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-08-2015, 08:37 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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.
 
Old 04-09-2015, 12:15 PM   #5
willc86
Member
 
Registered: Dec 2014
Posts: 54

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-09-2015, 12:58 PM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
Quote:
Originally Posted by willc86 View Post
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?

Last edited by suicidaleggroll; 04-09-2015 at 01:00 PM.
 
Old 04-09-2015, 01:11 PM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,143

Rep: Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350Reputation: 1350
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.
 
Old 04-09-2015, 01:22 PM   #8
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 7,678
Blog Entries: 10

Rep: Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080Reputation: 2080
Quote:
Originally Posted by willc86 View Post
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.
 
  


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
[SOLVED] an rsync question phantom630 Linux - Desktop 6 01-16-2011 07:04 PM
rsync question timl Linux - Newbie 4 12-04-2010 04:27 AM
rsync question nazs Linux - Software 1 10-23-2006 08:31 PM
rsync question kpachopoulos Linux - General 3 07-15-2005 04:33 PM
Question about rsync bgriesi Linux - Networking 4 12-31-2004 09:19 AM


All times are GMT -5. The time now is 03:10 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration