I have a script that uses
scp to backup some files of my PC into another PC connected in LAN, something like that:
#!/bin/bash scp some_directories host@ip-address:backupFolder/
I use a public Key so it works without insert any password, I have just to execute it.
The problem is that if I backup some file from my PC and then I remove it (from my PC not from the remote one), when I execute this script again it copy the new files and overwrites the existing ones but does not remove the previous backuped files that are no longer present in my PC.
So I need a way to remove files in the remote PC via some script. The only way I know is to login in with
ssh host@ip and then to use
rm but clearly I can't write a script like this:
#!/bin/bash ssh host@ip-address rm -r backupFolder/
because in this way the
rm command look for the backupFolder in my PC and not in the remote one.