I sync files on a few different devices with a remote ssh server using `rsync`. The problem is that I sometimes forget to sync a device on which I've modified a file and this makes things complicated. My first question is how to make syncing automatic in Ubuntu, I mean syncing when a file is modified but not "too often" (like when I'm working on a text file.)

Now a problem with automatic syncing is that if I screw up a file on one device it can propagate to others (and I may not even realize it when I delete a file by mistake). So I'd like to have backups on the remote server. Sometime ago I used the backup option in rsync but then the backed up files were synced back and forth and it created a mess. How can I have backups of the old files on the remote server without them being sent back to local devices? Is there any way to control how many back ups of each file are kept?