create backup for whole database using php
edit : backup_tables('your host address','username','password','db name');
example backup_tables('localhost','root','','test');
it will create .sql file in same folder where this code running
once you done it , if you wanto import .sql file using php see here https://github.com/Thamaraiselvam/Import-.sql-file-using-php