I'm relatively new to Linux and I'm trying to set up a script to backup machine A files to machine B. I have my ssh key all set up and can rsync just fine to copy files over, but I want to be able to run some additional commands on the remote host (the machine I'm connecting to) BEFORE
actually copying files over. I am new to shell scripting. Here is my script so far:
rsync -avz -e "ssh -i /home/theclient/.ssh/id_dsa 'rm -rf backup.3; mv backup.2 backup.3; mv backup.1 backup.2; cp -al backup.0 backup.1'" \
When I run the above script on machine A, I get the error:
ssh: rm -rf backup.3; mv backup.2 backup.3; mv backup.1 backup.2; cp -al backup.0 backup.1: Name or service not known
Whats the best way to embed those commands within the rsync/ssh command? Also, can I put those shell commands in a variable or function to tidy things up? I may have more commands to add to that so could get messy. I appreciate the help!