You’d need to setup a passwordless ssh key on one side or the other (so that the scp connection can take place without a password), or else add the password to the script (the former is probably preferable).
Basically, you’d want to do a mysqldump, make a tarball of the directories / files you want, and then scp the tarball to the other server.
There is documentation on creating ssh keys online, but basically:
server1% ssh-keygen -d
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa): [enter]
Enter passphrase (empty for no passphrase): [enter]
Enter same passphrase again: [enter]
server1% cat .ssh/id_dsa.pub | ssh server2 ‘cat >> .ssh/authorized_keys2 && chmod -R 0700 .ssh’’
you should now be able to ssh from server1 to server2 without a password.