LinuxQuestions.org
Review your favorite Linux distribution.
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 11-04-2016, 10:54 AM   #1
rsi142
LQ Newbie
 
Registered: Oct 2016
Posts: 9

Rep: Reputation: Disabled
rsync command


I am using rsync command for copying the file from remote server i had added the particular command in cron job so that every five minutes it will check the source file for the update and make the changes into it

but i had used stat command in order to know that is it creating new file or not i found that it is creating the new file everytime and making changes into it everytime

Is there any other way to just make the append the changes to the file
 
Old 11-04-2016, 11:03 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Im not entirely sure about your phrasing, but it seems that you are asking for rsync to only copy the changes/deltas of a file rather than the whole file. I would do this like this:

Code:
rsync -varh --progress --inplace --no-whole-file source destination

-v, --verbose               increase verbosity
-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
-r, --recursive             recurse into directories
-h, --human-readable        output numbers in a human-readable format
    --inplace               update destination files in-place
    --no-whole-files        copy file changes (with delta-xfer algorithm)
Here's how you can verify:

Code:
$ mkdir a b
$ dd if=/dev/zero of=a/1 bs=1k count=64
$ dd if=/dev/zero of=a/2 bs=1k count=64
$ dd if=/dev/zero of=a/3 bs=1k count=64
$ rsync -av a/ b/
sending incremental file list
./
1
2
3

sent 196831 bytes  received 72 bytes  393806.00 bytes/sec
total size is 196608  speedup is 1.00
Then touch a file and re-sync

Code:
$ touch a/1
$ rsync -av --inplace a/ b/
sending incremental file list
1

sent 65662 bytes  received 31 bytes  131386.00 bytes/sec
total size is 196608  speedup is 2.99
You can verify it re-used the inode with "ls -li", but notice it sent a whole 64K bytes. Try again with --no-whole-file

Code:
$ touch a/1
$ rsync -av --inplace --no-whole-file a/ b/
sending incremental file list
1

sent 494 bytes  received 595 bytes  2178.00 bytes/sec
total size is 196608  speedup is 180.54
Now you've only sent 494 bytes. You could use strace to further verify if any of the file was written, but this shows it at least used delta-transfer.

**Test information from stackexchange @dataless http://superuser.com/questions/57603...s-that-need-to cc by-sa 3.0

Last edited by szboardstretcher; 11-04-2016 at 11:06 AM.
 
Old 11-04-2016, 11:10 AM   #3
rsi142
LQ Newbie
 
Registered: Oct 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
so if i use rsync -inplace username@ip :source destination
then the inode would remain same
 
Old 11-04-2016, 11:16 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
yes
 
  


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] rsync command does not work figure20012 Linux - Newbie 13 08-01-2012 06:48 AM
Help with rsync command anon091 Linux - Newbie 3 10-20-2011 02:44 AM
rsync command problem aman_m03 Fedora 1 01-21-2011 05:58 AM
rsync problems, can you look at my command? - Rsync gurus. Spuddy Linux - Software 4 09-21-2010 10:25 AM
[SOLVED] rsync command windstory Linux - Newbie 2 08-10-2010 01:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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