On Thu, Feb 21, 2013 at 02:46:43PM +0300, Johannes Graumann wrote:
> Hi,
>
> deja-dup has an option to keep backups forever or until storage on the drive
> backed up to runs short (at which point it starts deleting old backups).
> Does someone have any pointers on how to copy that behavior using duplicity
> and/or other CLI tools?
This isn't tested, just typed into mutt, so I might have some syntax
errors.
#!/bin/bash
if [[ ! -d ~/.backup ]]; then
mkdir ~/.backup
fi
FreeSpace=$(df -PB1 ~/.backup|awk 'NR==2 {print $4}')
FileSize=$(stat -c='%s' $1)
if (( $FileSize >= $FreeSpace )); then
# No room to copy file. Clear out oldest file
rm $(ls -tr ~/.backup|tail -n 1)
fi
cp $1 ~/.backup/$1.$(date +'%Y%m%d')
---------------------
Eliminating race conditions etc are left as an exercise for the reader
:)
Attachment:
signature.asc
Description: Digital signature