I am implementing an automated backup scheme so I created
a shell
script which first creates SQL Dumps
for all MySQL databases, then it retrieves all the websites from the /var/www of
a remote server. The latter is working as I am using rsync to get the remote files.
However, obviously, the MySQL dumps being retrieved are the ones on the local server which is not what I want. I want to get the SQL Dumps from the remote server as well.
I have
a tunnel between the local and remote server which I can connect without using any password (I added the public key to the authorized_hosts), so I tried to add the following code to the script:
ssh
[email protected]
Then I tried to retrieve the SQL dumps and then I exit from the remote server. However this does not work as I still have to enter exit manually in the terminal
for the SQL dumps to be retrieved from the remote host. I don't know why this is happening. Basically this is what the
script is trying to do:
//connect to remote server
ssh
[email protected]
//retrieve SQL dumps
//code to retrieve...
//exit from remote server
exit
//use rsync to get remote files of /var/www from local server (working)
Is there
a way to connect to the remote host AND run the
script's code ON THAT remote host?
Many thanks in advance