--backup trickery
Jason Marshall
jasonm at kelman.com
Tue Jul 5 17:48:10 GMT 2005
Greetings. I looked through the archives and didn't find anything useful
in there (in regard to this question, at least). My environment is
primarily Solaris, with some Linux. Sorry about the long preamble, but
I've done it to avoid you having to ask me questions that I could easily
answer up front.
As you are likely aware, when you use the --backup option, and the
--backup-dir is on the same filesystem as the original file, the original
file is moved rather than copied into the backup directory, maintaining
its inode number. The moved copy is exactly the same file as what used to
be in the main directory heirarchy, and because the inode number is the
same, anything that had that file open will not notice that anything
strange is afoot.
I am abusing this feature to allow currently-running executables and
shared libraries to be rsynced without causing any corruption (the file is
moved, then presumably copied back to the original location, and then
rsynced, while the running process is using the file in the backup
directory). Of course any new process using the 1/2-rsynced copy in the
original location may die, but it's the already-running ones I'm far more
concerned with. Some of our processes will run for weeks.
In addition to this bit of trickery, after the rsync is complete, I delete
the backup directory. Again, as most of you are likely aware, a
deleted-but-still-open file in unix isn't really deleted until it is
closed. Therefore, even though I delete the backup directory, the file
still exists as far as any processes who have that file open are
concerned. When said processes are complete, the file is deleted, finally
freeing up the space it was taking up.
What I'd really like to see is an option that might be called
--delete-backups where the backup is made, and immediately deleted -- the
backup, not the original file. This would allow me to use the two tricks
outlined above without requiring a lot of filesystem head-room to store
all the backups before deleting them in a seperate process at the end of
the rsync.
Am I the only one who would like something like this? Is there already a
way to do this using rsync tricks? I'm interested in any ideas people may
have about this. Thanks for your time!
---
Jason Marshall, Unix Geek, Kelman Technologies, Inc., Calgary, AB, Canada.
From a Sun Microsystems bug report (#4102680):
"Workaround: don't pound on the mouse like a wild monkey."
"I have great faith in fools:
Self confidence my friends call it." -Edgar Allan Poe
More information about the rsync
mailing list