On 03/06/2017 11:35 PM, Jean-Christophe Bach wrote:
> Hello,
> 
>> I was looking at this rotating backup script
>>
>> source:
>> https://community.spiceworks.com/topic/34970-how-to-create-rotating-backups-of-files
>>
>> ----------backup script----------------
>> BACKUPDIR=`date +%A`
>> OPTS="--force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES 
>>       --delete --backup --backup-dir=/$BACKUPDIR -a"
>>
>> export PATH=$PATH:/bin:/usr/bin:/usr/local/bin
>>
>> # the following line clears the last weeks incremental directory
>> [ -d $HOME/emptydir ] || mkdir $HOME/emptydir
>> rsync --delete -a $HOME/emptydir/ $BSERVER::$USER/$BACKUPDIR/
>> rmdir $HOME/emptydir
>>
>> # now the actual transfer
>> rsync $OPTS $BDIR $BSERVER::$USER/current
>> -------end backup script----------------
>>
>> Can anybody explain why they they "...clear the last weeks incremental 
>> directory"?
> 
> Probably because BACKUPDIR is set to the name of the day (`date +`A`).
> Today is Tuesday and a backup is done, next week the backup will be
> overwritten because BACKUPDIR will also be Tuesday. Therefore there will
> only be 7 directories.
> 
>> Doesn't "rsync --deleate" option take take care of this?
> 
> --delete removes extraneous files. Combined with the previous thing, it
> ensures the backup rotation.
> 
[snip]

Yes, the script clear states there will be 7-backups.
But I see no reason to remove/clear old backup from previous week since
"--delete" will remove all the file on destination that are not in source.

That is just a redundant step, I think.

--
Thelma

Reply via email to