You are not logged in.

#1 2015-10-21 08:02:10

JASN
Member
Registered: 2009-04-17
Posts: 18

[Solved] How to tell rsync not to overwrite existing files...

Hi everyone!

First a bit of background information: I am doing regular backups of all my machines to a server at home, and the same at my parents' house. Both backup targets are Arch-based and I use a combination of FTP and rsync. Now the next step would be to create actual offsite backups by syncing my parents backup to my server and vice versa.
The plan was to simply rsync everything, so in order to speed up the process I exchanged backup sets between my server and my parents', and then to tell rsync to do checksumming, in the hope it would then only transfer files that actually changed in the meantime.

My command looks like this:

rsync -acz {parent location} {my location}

So not really complicated. The problem now is, rsync apparently does checksumming, but ignores it and does a first sync anyway. I do not want to use the "--ignore-existing" switch, because some of the existing files might have changed. Is there a way to tell rsync to handle the USB-copied files via the checksum and ignore them?

Last edited by JASN (2015-10-27 10:02:21)

Offline

#2 2015-10-21 08:30:12

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,730
Website

Re: [Solved] How to tell rsync not to overwrite existing files...

Consult the man page but I think you want the -u switch.

Offline

#3 2015-10-21 10:51:15

JASN
Member
Registered: 2009-04-17
Posts: 18

Re: [Solved] How to tell rsync not to overwrite existing files...

No, already tried that, too. Apparently rsync doesn't like checking files that were written there another way. Oh well, guess i'll have to bite the bullet and transfer 190Gigs in total.

Offline

#4 2015-10-21 13:27:14

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,730
Website

Re: [Solved] How to tell rsync not to overwrite existing files...

I don't know.  You can use the --dryrun option on invocation to see what rsync will do with the proposed switches you're trying.

Offline

#5 2015-10-21 16:36:07

branch
Member
Registered: 2014-03-16
Posts: 209

Re: [Solved] How to tell rsync not to overwrite existing files...

JASN wrote:

No, already tried that, too. Apparently rsync doesn't like checking files that were written there another way. Oh well, guess i'll have to bite the bullet and transfer 190Gigs in total.

rsync does not know or care how a file was written. With "-c", rsync should check file size first, then MD5 sum. Get the list of files rsync believes need to be copied with "-v --dry-run", NOT "--list-only" as this lists all files in the complete set. If you believe it to be copying a particular file unnecessarily, compare the size and MD5 sum of the source and destination to make sure they actually match.

On a side note you probably want some extra rsync options:
"--delete" will prevent deleted files from persisting in the backup set forever
"--numeric-ids" will prevent problems with uid/gid mismatch between the various systems involved

Offline

#6 2015-10-27 09:59:46

JASN
Member
Registered: 2009-04-17
Posts: 18

Re: [Solved] How to tell rsync not to overwrite existing files...

So apparently it was all just PEBKAC...
I took along a new copy of the files to my parents, deleted the whole old directory structure, copied in the new structure, ran the script, and voilà, it works as it was supposed to. I have no idea what I did differently the last time, though.

[Edit]

As it is no longer an open problem, how do i change the thread title?

[Edit2]

Nevermind, edited first post.

Last edited by JASN (2015-10-27 10:02:44)

Offline

Board footer

Powered by FluxBB