bash script – download wp code and database dump from server

#!/bin/bash
#ssh into server, zip code, create mysqldump
ssh ubuntu@aws "zip -r /home/folderinmyserver/mycode.zip /home/folderinmyserver/mycode; mysqldump --defaults-extra-file=/home/folderinmyserver/my.cnf --no-tablespaces mydatabasename > /home/folderinmyserver/dump.sql"

# download zipped code
scp ubuntu@aws:/home/folderinmyserver/mycode.zip /home/myname/

# download dump
scp ubuntu@aws:/home/folderinmyserver/dump.sql /home/myname/

Previously I created a file for storing database credentials /home/folderinmyserver/my.cnf:

[client]
user = "myusername"
password = "mypass"
host = "myhost"