Question: I use `rsync` as follows:

> 
> rsync -a --backup --suffix="."$(date +"%Y%m%d%H%M") *source backups*
> 
> 
> 

to dump the whole of folder *source* into the folder *backups*, with the additional feature that if I modify some file *foo* in *source*, the old version of *foo* in backups will be renamed with a date suffix before the new *foo* is copied into *backups*.

This simple procedure does the job for me, only that I would like a **deleted** file to be **renamed** with the date suffix instead of being removed from *backups*. That is, if *foo* is deleted from source, then rename *foo* in *backups* with the date suffix.

I have tried to achieve this but so far no success. Any ideas?

Answer: 
Add the `--delete` option to your `rsync` command. `--delete` tells rsync that when it sees a file that is in the destination but not the source, it should delete it from the destination - except since you are also using `--backup`, instead of deleting the file it will rename and/or move it, depending on whether you've specified a `--suffix` and/or `--backup-dir`. 

In your case since you have specified a suffix that changes from run to run, you'll need to add a protect filter rule so that files previously backed up with a suffix don't get get renamed again: 

`--filter='P *.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'`

That filter pattern looks for filenames ending in a dot and then 12 digits, which is the format of your date suffix. That suffix is a bit ambiguous, so I'd suggest using some other format with some special character(s) or a unique string in the suffix, so that ordinary files won't be mistaken for backup files.
For incremental rsync backup used rsnapshot tool.

Sample rsnapshot.conf

```
snapshot_root   /backup

cmd_cp          /bin/cp

cmd_rm          /bin/rm

cmd_rsync       /usr/bin/rsync

cmd_ssh /usr/bin/ssh

cmd_logger      /usr/bin/logger

cmd_du          /usr/bin/du

cmd_rsnapshot_diff      /usr/bin/rsnapshot-diff

retain          daily   7
retain          weekly  4

verbose         2

loglevel        3

logfile /var/log/rsnapshot.log

lockfile        /var/run/rsnapshot.pid

backup  root@localhost:/etc/                   localhost/
backup  root@localhost:/home                   localhost/
backup  root@localhost:/var/www/               localhost/

```

Set Cronjobs For auto backup:

```
# m     h   dom mon dow command
#Run Rsnapshot At 02:00 Everyday
00      02      *       *       *       /usr/bin/rsnapshot daily
#Run Rsnapshot At 06:00 Every Sunday 
00      06      *       *       0       /usr/bin/rsnapshot weekly

```