-   Linux - Software (
-   -   tool to sync files considering free space left on target (

lentschi 03-23-2008 07:06 AM

tool to sync files considering free space left on target
Hey all!

I'm in need of a command line tool much like rsync to do an exact copy of a specified folder. (Meaning all the files, that were deleted in the source folder shall also be deleted in the target folder)

I know this can be done using something like:

rsync -a --delete /source/folder /target/folder
However I'd prefer a slightly different behaviour:
Files should only be deleted if there is no space left on the target. With other words: Only as many files as necessary should be deleted. (It would be a great bonus if the files that were only deleted a short time ago in the source directory survive longest in the target directory)

I'd like to use this as a backup tool - So if a files gets deleted in the source directory there'd be at least a slight chance that it would still be there in the target directory.

Is there anything like that? (Is it probably just another rsync parameter I missed?)

hob 03-24-2008 11:30 AM

This probably isn't the right approach... How do you decide (or know later) exactly what is less important and can be safely thrown away? The value of a backup is really that it lets you be sure that you can get back multiple known previous versions on demand.

You can run commands to the remote machine over SSH in a script and then run rsync with flags based on the results if you need to fine-tune the sync, but I don't recommend that you use rsync cloning for data backup. rdiff-backup is a good command-line backup tool that is specifically designed to maintain multiple versions of your files in a space-efficient way.

lentschi 03-25-2008 04:54 AM

Yeah - I guess, you're right...
I was already going to write a script myself, when I realized that this might not be good backup practice. People would start depending on the fact that there are backups even of the files they deleted the day before. But the truth is we just don't have enough hard disk space to assure this. So it's probably better to backup only existing files.
Thanks for your reply!

All times are GMT -5. The time now is 06:50 PM.