|
You can use rsync for this. Rsync works over ssh as well. If you have to write your own script, you can do something like this:
1. ssh to remote and get list of files (use ssh and ls on remote path)
2. compare remote list with local list and create list of files to remove (files that are not present locally) (use comm command)
3. ssh to remote and remove files that are in the list (use ssh and rm on remote path)
4. scp files from local to remote (scp as in current script)
|