Using rsync, how can I know what attribute of source file differed from the dest which caused the trasfer Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionDelete the files on the destination which are found in the source using rsyncCan rsync be configured to avoid modifying subdirectories not found in the source folder?how to get rsync to link identical files with --link-dest option if an old file already exists?File corruption using rsync, multiple rsync processes, moved/renamed source fileHow do I avoid the creation of root folder of the source in the destination when using rsync?Why is my rsync slow?Proper way to create a compressed, rsyncable mirror of a directory?Why isn't rsync using delta transfers for a single file across a network?What differences are between using `-u` and not with rsync?Help with script/rsync command to move file with md5 sum comparison before deleting the source file/
Is the Standard Deduction better than Itemized when both are the same amount?
Generate an RGB colour grid
Should I use a zero-interest credit card for a large one-time purchase?
Can anything be seen from the center of the Boötes void? How dark would it be?
For a new assistant professor in CS, how to build/manage a publication pipeline
How do I make this wiring inside cabinet safer? (Pic)
Crossing US/Canada Border for less than 24 hours
Why are both D and D# fitting into my E minor key?
Is safe to use va_start macro with this as parameter?
When the Haste spell ends on a creature, do attackers have advantage against that creature?
Using audio cues to encourage good posture
What is implied by the word 'Desika'
Trademark violation for app?
2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?
How do I find out the mythology and history of my Fortress?
How to Make a Beautiful Stacked 3D Plot
What are the out-of-universe reasons for the references to Toby Maguire-era Spider-Man in ITSV
How would a mousetrap for use in space work?
Dating a Former Employee
What would be the ideal power source for a cybernetic eye?
Maximum summed powersets with non-adjacent items
Does classifying an integer as a discrete log require it be part of a multiplicative group?
Why do we bend a book to keep it straight?
An adverb for when you're not exaggerating
Using rsync, how can I know what attribute of source file differed from the dest which caused the trasfer
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionDelete the files on the destination which are found in the source using rsyncCan rsync be configured to avoid modifying subdirectories not found in the source folder?how to get rsync to link identical files with --link-dest option if an old file already exists?File corruption using rsync, multiple rsync processes, moved/renamed source fileHow do I avoid the creation of root folder of the source in the destination when using rsync?Why is my rsync slow?Proper way to create a compressed, rsyncable mirror of a directory?Why isn't rsync using delta transfers for a single file across a network?What differences are between using `-u` and not with rsync?Help with script/rsync command to move file with md5 sum comparison before deleting the source file/
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I heavily depend on rsync
for remote data transfer and backup purposes, occasionally on different filesystem types. AFAIK rsync
by default compares file size and modification timestamps to find out which files need to be transfered. This behavior can be changed to just file sizes using --size-only
flag and can be replaced by file checksums using --checksum
flag.
Sometimes It's not quite clear to me why rsync
decides a big tree of files should be re-transfered, when I know destination has the same data as source.
Is there an rsync option or something similar which helps to easily find out the difference between two file trees, for example for each file it could print one of timestamps, owner/group, permissions, file size/content, etc.
rsync
add a comment |
I heavily depend on rsync
for remote data transfer and backup purposes, occasionally on different filesystem types. AFAIK rsync
by default compares file size and modification timestamps to find out which files need to be transfered. This behavior can be changed to just file sizes using --size-only
flag and can be replaced by file checksums using --checksum
flag.
Sometimes It's not quite clear to me why rsync
decides a big tree of files should be re-transfered, when I know destination has the same data as source.
Is there an rsync option or something similar which helps to easily find out the difference between two file trees, for example for each file it could print one of timestamps, owner/group, permissions, file size/content, etc.
rsync
2
Maybe the--verbose
or--itemize-changes
options do what you want?
– Barmar
Oct 22 '14 at 18:54
add a comment |
I heavily depend on rsync
for remote data transfer and backup purposes, occasionally on different filesystem types. AFAIK rsync
by default compares file size and modification timestamps to find out which files need to be transfered. This behavior can be changed to just file sizes using --size-only
flag and can be replaced by file checksums using --checksum
flag.
Sometimes It's not quite clear to me why rsync
decides a big tree of files should be re-transfered, when I know destination has the same data as source.
Is there an rsync option or something similar which helps to easily find out the difference between two file trees, for example for each file it could print one of timestamps, owner/group, permissions, file size/content, etc.
rsync
I heavily depend on rsync
for remote data transfer and backup purposes, occasionally on different filesystem types. AFAIK rsync
by default compares file size and modification timestamps to find out which files need to be transfered. This behavior can be changed to just file sizes using --size-only
flag and can be replaced by file checksums using --checksum
flag.
Sometimes It's not quite clear to me why rsync
decides a big tree of files should be re-transfered, when I know destination has the same data as source.
Is there an rsync option or something similar which helps to easily find out the difference between two file trees, for example for each file it could print one of timestamps, owner/group, permissions, file size/content, etc.
rsync
rsync
asked Oct 22 '14 at 12:55
zaadehzaadeh
4961715
4961715
2
Maybe the--verbose
or--itemize-changes
options do what you want?
– Barmar
Oct 22 '14 at 18:54
add a comment |
2
Maybe the--verbose
or--itemize-changes
options do what you want?
– Barmar
Oct 22 '14 at 18:54
2
2
Maybe the
--verbose
or --itemize-changes
options do what you want?– Barmar
Oct 22 '14 at 18:54
Maybe the
--verbose
or --itemize-changes
options do what you want?– Barmar
Oct 22 '14 at 18:54
add a comment |
1 Answer
1
active
oldest
votes
First, if there is such an option in rsync, I am not aware of it and cannot find it in the man page. This is unfortunate, since it would provide what you need quickly, and presumably for any possible rsync
use case.
Second, I think that if one were to try to do this with existing rsync options (basically --dry-run combined with a glut of possible combinations of checksum, date-is-newer, date-is-older, file-should-be-deleted, ad infinitum) would require several passes of rsync
, one for each possible reason a file might get rsync
ed across. This seems unwieldy for your purposes.
If you can deal with a tool that compares two trees and reports the differences and interpolating its output to suit your needs, then mtree
might work for your needs.
mtree
is specifically designed to compare two directory trees and report the differences.
On the source machine, create an mtree spec (including sha256 hash) of your desired source tree:
# mtree -K sha256 -cp /my_path > my_path.mtree
Then rsync
the tree across, and run mtree on the remote machine to see whether the remote directory tree /remote_path matches the local /my_path:
# rsync -a --delete /my_path/ remote:/remote_path/
# ssh remote mtree -p /remote_path < my_path.mtree && echo match
match
Now let's go mess with the remote tree a little. Long story short, I created a destination file farkle
which doesn't exist on the source, removed a file file.txt
, and changed the timestamp on a file data.txt
.
# ssh remote mtree -p remote_path < my_path.mtree || echo fail
.: modification time (Wed Apr 17 10:49:32 2019, Wed Apr 17 11:55:10 2019)
extra: farkle
data.txt:
modification time (Wed Apr 17 10:45:02 2019, Wed Apr 17 11:56:27 2019)
foo: size (32, 29)
modification time (Tue Apr 16 10:16:44 2019, Wed Apr 17 11:53:18 2019)
sha256digest (0x6082aa7261362c4c71c82adf492bc724de53a5814e64b233c43c6775efeb1dd0, 0x2d2537ea27c27dfb2c1690c51c652b9ada32adc29a91b732c24939dcff371cd6)
./file.txt missing
fail
mtree
is informing you that:
farkle
exists on the destination, but not the source; it would be
deleted if you specify --delete in yourrsync
command line.data.txt
has not changed in content (sha256 hash) or size, but has
a newer timestamp; copying based on checksum alone might not re-transfer the file, nor wouldrsync
ing only "newer" files, since the destination's file is now newer than the source.file.txt
is absent on the destination host, and would presumably bersync
ed across on the next run, barring some exclusion criterion.
So this doesn't quite give you a direct rationale from rsync about why it is or isn't copying what you think it should, but it does give you a hard, verifiable report of what is actually on the ground with respect to the local and remote directory trees.
If you retain the my_path.mtree
output file methodically, such as by including a datestamp in the filename, you can also run mtree
on the local machine to compare the existing /my_path tree against a previous run (yesterday's? last week's?) to see whether something has changed locally that you might not have been expecting.
mtree
is included in some Unix distributions, but if yours is lacking mtree, I have had success installing Archie Cobbs' version from GitHub.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f163591%2fusing-rsync-how-can-i-know-what-attribute-of-source-file-differed-from-the-dest%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First, if there is such an option in rsync, I am not aware of it and cannot find it in the man page. This is unfortunate, since it would provide what you need quickly, and presumably for any possible rsync
use case.
Second, I think that if one were to try to do this with existing rsync options (basically --dry-run combined with a glut of possible combinations of checksum, date-is-newer, date-is-older, file-should-be-deleted, ad infinitum) would require several passes of rsync
, one for each possible reason a file might get rsync
ed across. This seems unwieldy for your purposes.
If you can deal with a tool that compares two trees and reports the differences and interpolating its output to suit your needs, then mtree
might work for your needs.
mtree
is specifically designed to compare two directory trees and report the differences.
On the source machine, create an mtree spec (including sha256 hash) of your desired source tree:
# mtree -K sha256 -cp /my_path > my_path.mtree
Then rsync
the tree across, and run mtree on the remote machine to see whether the remote directory tree /remote_path matches the local /my_path:
# rsync -a --delete /my_path/ remote:/remote_path/
# ssh remote mtree -p /remote_path < my_path.mtree && echo match
match
Now let's go mess with the remote tree a little. Long story short, I created a destination file farkle
which doesn't exist on the source, removed a file file.txt
, and changed the timestamp on a file data.txt
.
# ssh remote mtree -p remote_path < my_path.mtree || echo fail
.: modification time (Wed Apr 17 10:49:32 2019, Wed Apr 17 11:55:10 2019)
extra: farkle
data.txt:
modification time (Wed Apr 17 10:45:02 2019, Wed Apr 17 11:56:27 2019)
foo: size (32, 29)
modification time (Tue Apr 16 10:16:44 2019, Wed Apr 17 11:53:18 2019)
sha256digest (0x6082aa7261362c4c71c82adf492bc724de53a5814e64b233c43c6775efeb1dd0, 0x2d2537ea27c27dfb2c1690c51c652b9ada32adc29a91b732c24939dcff371cd6)
./file.txt missing
fail
mtree
is informing you that:
farkle
exists on the destination, but not the source; it would be
deleted if you specify --delete in yourrsync
command line.data.txt
has not changed in content (sha256 hash) or size, but has
a newer timestamp; copying based on checksum alone might not re-transfer the file, nor wouldrsync
ing only "newer" files, since the destination's file is now newer than the source.file.txt
is absent on the destination host, and would presumably bersync
ed across on the next run, barring some exclusion criterion.
So this doesn't quite give you a direct rationale from rsync about why it is or isn't copying what you think it should, but it does give you a hard, verifiable report of what is actually on the ground with respect to the local and remote directory trees.
If you retain the my_path.mtree
output file methodically, such as by including a datestamp in the filename, you can also run mtree
on the local machine to compare the existing /my_path tree against a previous run (yesterday's? last week's?) to see whether something has changed locally that you might not have been expecting.
mtree
is included in some Unix distributions, but if yours is lacking mtree, I have had success installing Archie Cobbs' version from GitHub.
add a comment |
First, if there is such an option in rsync, I am not aware of it and cannot find it in the man page. This is unfortunate, since it would provide what you need quickly, and presumably for any possible rsync
use case.
Second, I think that if one were to try to do this with existing rsync options (basically --dry-run combined with a glut of possible combinations of checksum, date-is-newer, date-is-older, file-should-be-deleted, ad infinitum) would require several passes of rsync
, one for each possible reason a file might get rsync
ed across. This seems unwieldy for your purposes.
If you can deal with a tool that compares two trees and reports the differences and interpolating its output to suit your needs, then mtree
might work for your needs.
mtree
is specifically designed to compare two directory trees and report the differences.
On the source machine, create an mtree spec (including sha256 hash) of your desired source tree:
# mtree -K sha256 -cp /my_path > my_path.mtree
Then rsync
the tree across, and run mtree on the remote machine to see whether the remote directory tree /remote_path matches the local /my_path:
# rsync -a --delete /my_path/ remote:/remote_path/
# ssh remote mtree -p /remote_path < my_path.mtree && echo match
match
Now let's go mess with the remote tree a little. Long story short, I created a destination file farkle
which doesn't exist on the source, removed a file file.txt
, and changed the timestamp on a file data.txt
.
# ssh remote mtree -p remote_path < my_path.mtree || echo fail
.: modification time (Wed Apr 17 10:49:32 2019, Wed Apr 17 11:55:10 2019)
extra: farkle
data.txt:
modification time (Wed Apr 17 10:45:02 2019, Wed Apr 17 11:56:27 2019)
foo: size (32, 29)
modification time (Tue Apr 16 10:16:44 2019, Wed Apr 17 11:53:18 2019)
sha256digest (0x6082aa7261362c4c71c82adf492bc724de53a5814e64b233c43c6775efeb1dd0, 0x2d2537ea27c27dfb2c1690c51c652b9ada32adc29a91b732c24939dcff371cd6)
./file.txt missing
fail
mtree
is informing you that:
farkle
exists on the destination, but not the source; it would be
deleted if you specify --delete in yourrsync
command line.data.txt
has not changed in content (sha256 hash) or size, but has
a newer timestamp; copying based on checksum alone might not re-transfer the file, nor wouldrsync
ing only "newer" files, since the destination's file is now newer than the source.file.txt
is absent on the destination host, and would presumably bersync
ed across on the next run, barring some exclusion criterion.
So this doesn't quite give you a direct rationale from rsync about why it is or isn't copying what you think it should, but it does give you a hard, verifiable report of what is actually on the ground with respect to the local and remote directory trees.
If you retain the my_path.mtree
output file methodically, such as by including a datestamp in the filename, you can also run mtree
on the local machine to compare the existing /my_path tree against a previous run (yesterday's? last week's?) to see whether something has changed locally that you might not have been expecting.
mtree
is included in some Unix distributions, but if yours is lacking mtree, I have had success installing Archie Cobbs' version from GitHub.
add a comment |
First, if there is such an option in rsync, I am not aware of it and cannot find it in the man page. This is unfortunate, since it would provide what you need quickly, and presumably for any possible rsync
use case.
Second, I think that if one were to try to do this with existing rsync options (basically --dry-run combined with a glut of possible combinations of checksum, date-is-newer, date-is-older, file-should-be-deleted, ad infinitum) would require several passes of rsync
, one for each possible reason a file might get rsync
ed across. This seems unwieldy for your purposes.
If you can deal with a tool that compares two trees and reports the differences and interpolating its output to suit your needs, then mtree
might work for your needs.
mtree
is specifically designed to compare two directory trees and report the differences.
On the source machine, create an mtree spec (including sha256 hash) of your desired source tree:
# mtree -K sha256 -cp /my_path > my_path.mtree
Then rsync
the tree across, and run mtree on the remote machine to see whether the remote directory tree /remote_path matches the local /my_path:
# rsync -a --delete /my_path/ remote:/remote_path/
# ssh remote mtree -p /remote_path < my_path.mtree && echo match
match
Now let's go mess with the remote tree a little. Long story short, I created a destination file farkle
which doesn't exist on the source, removed a file file.txt
, and changed the timestamp on a file data.txt
.
# ssh remote mtree -p remote_path < my_path.mtree || echo fail
.: modification time (Wed Apr 17 10:49:32 2019, Wed Apr 17 11:55:10 2019)
extra: farkle
data.txt:
modification time (Wed Apr 17 10:45:02 2019, Wed Apr 17 11:56:27 2019)
foo: size (32, 29)
modification time (Tue Apr 16 10:16:44 2019, Wed Apr 17 11:53:18 2019)
sha256digest (0x6082aa7261362c4c71c82adf492bc724de53a5814e64b233c43c6775efeb1dd0, 0x2d2537ea27c27dfb2c1690c51c652b9ada32adc29a91b732c24939dcff371cd6)
./file.txt missing
fail
mtree
is informing you that:
farkle
exists on the destination, but not the source; it would be
deleted if you specify --delete in yourrsync
command line.data.txt
has not changed in content (sha256 hash) or size, but has
a newer timestamp; copying based on checksum alone might not re-transfer the file, nor wouldrsync
ing only "newer" files, since the destination's file is now newer than the source.file.txt
is absent on the destination host, and would presumably bersync
ed across on the next run, barring some exclusion criterion.
So this doesn't quite give you a direct rationale from rsync about why it is or isn't copying what you think it should, but it does give you a hard, verifiable report of what is actually on the ground with respect to the local and remote directory trees.
If you retain the my_path.mtree
output file methodically, such as by including a datestamp in the filename, you can also run mtree
on the local machine to compare the existing /my_path tree against a previous run (yesterday's? last week's?) to see whether something has changed locally that you might not have been expecting.
mtree
is included in some Unix distributions, but if yours is lacking mtree, I have had success installing Archie Cobbs' version from GitHub.
First, if there is such an option in rsync, I am not aware of it and cannot find it in the man page. This is unfortunate, since it would provide what you need quickly, and presumably for any possible rsync
use case.
Second, I think that if one were to try to do this with existing rsync options (basically --dry-run combined with a glut of possible combinations of checksum, date-is-newer, date-is-older, file-should-be-deleted, ad infinitum) would require several passes of rsync
, one for each possible reason a file might get rsync
ed across. This seems unwieldy for your purposes.
If you can deal with a tool that compares two trees and reports the differences and interpolating its output to suit your needs, then mtree
might work for your needs.
mtree
is specifically designed to compare two directory trees and report the differences.
On the source machine, create an mtree spec (including sha256 hash) of your desired source tree:
# mtree -K sha256 -cp /my_path > my_path.mtree
Then rsync
the tree across, and run mtree on the remote machine to see whether the remote directory tree /remote_path matches the local /my_path:
# rsync -a --delete /my_path/ remote:/remote_path/
# ssh remote mtree -p /remote_path < my_path.mtree && echo match
match
Now let's go mess with the remote tree a little. Long story short, I created a destination file farkle
which doesn't exist on the source, removed a file file.txt
, and changed the timestamp on a file data.txt
.
# ssh remote mtree -p remote_path < my_path.mtree || echo fail
.: modification time (Wed Apr 17 10:49:32 2019, Wed Apr 17 11:55:10 2019)
extra: farkle
data.txt:
modification time (Wed Apr 17 10:45:02 2019, Wed Apr 17 11:56:27 2019)
foo: size (32, 29)
modification time (Tue Apr 16 10:16:44 2019, Wed Apr 17 11:53:18 2019)
sha256digest (0x6082aa7261362c4c71c82adf492bc724de53a5814e64b233c43c6775efeb1dd0, 0x2d2537ea27c27dfb2c1690c51c652b9ada32adc29a91b732c24939dcff371cd6)
./file.txt missing
fail
mtree
is informing you that:
farkle
exists on the destination, but not the source; it would be
deleted if you specify --delete in yourrsync
command line.data.txt
has not changed in content (sha256 hash) or size, but has
a newer timestamp; copying based on checksum alone might not re-transfer the file, nor wouldrsync
ing only "newer" files, since the destination's file is now newer than the source.file.txt
is absent on the destination host, and would presumably bersync
ed across on the next run, barring some exclusion criterion.
So this doesn't quite give you a direct rationale from rsync about why it is or isn't copying what you think it should, but it does give you a hard, verifiable report of what is actually on the ground with respect to the local and remote directory trees.
If you retain the my_path.mtree
output file methodically, such as by including a datestamp in the filename, you can also run mtree
on the local machine to compare the existing /my_path tree against a previous run (yesterday's? last week's?) to see whether something has changed locally that you might not have been expecting.
mtree
is included in some Unix distributions, but if yours is lacking mtree, I have had success installing Archie Cobbs' version from GitHub.
answered 11 hours ago
Jim L.Jim L.
22114
22114
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f163591%2fusing-rsync-how-can-i-know-what-attribute-of-source-file-differed-from-the-dest%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
-rsync
2
Maybe the
--verbose
or--itemize-changes
options do what you want?– Barmar
Oct 22 '14 at 18:54