Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
rsync copied 0-byte source file
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
nordic bro
Guru
Guru


Joined: 25 Oct 2003
Posts: 585

PostPosted: Fri Sep 27, 2013 7:16 pm    Post subject: rsync copied 0-byte source file Reply with quote

I'm kind of new to rsync and this is the cmd I use:

rsync -axu --delete

there are a number of source partitions I backup to similarly-sized target partitions on a separate disc. I run "$rsync_cmd $source/ $target/" from a script and after lots of double-checking initially it seemed to have been working great for many months.

the other day in source /etc I came across 0-byte ntp.conf and have no idea how that happened. so I mounted the corresponding rsync target to copy the file back but found its npt.conf was also 0-byte.

that 0-byte file was the only one in target /etc, all the rest there looked ok so it seems my source ntp.conf got wiped out and when I did a subsequent rsync my good target copy got replaced.

so is there an rsync option I can add that would tell rsync to never replace something on target w/0-byte source file?

thanks.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9677
Location: almost Mile High in the USA

PostPosted: Sat Sep 28, 2013 12:06 am    Post subject: Reply with quote

What if you deliberately zeroed out the file and needed an empty file, and needed a full restore - you'd also end up with a broken system.

Maybe the best way is to RCS all of these files... but the original way to deal with this is to have rotating and incremental backups or a version controlled filesystem.

I suppose the least software way to do this is to use

find /sourcedir -size 0 -type f > /tmp/newzerosized.txt
find /destdir -size 0 -type f > /tmp/oldzerosized.txt
[insert magic here to remove all old zerosized files from newzerosized file list]

to find empty files, and tell rsync --exclude-from /tmp/skipzerosized.txt to skip them. Or you could do away with checking old ones and just let it skip them too even if they've never been copied.

Not a very clean solution either way...

(I was experimenting with a deduplication filesystem as backup, but lessfs is crap for large number of small file backups.)
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21607

PostPosted: Sat Sep 28, 2013 3:03 pm    Post subject: Reply with quote

According to man rsync, you can use --min-size to implement this. However, as eccerr0r says, this may not be the right choice in some situations, so think carefully before deploying it across a large area.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum