• Just so you're clear on terminology.

    A backup is a page-by-page copy of the database including all the database objects and the data inside the database.

    You're asking for a script for recreating the database. There isn't a command for automating exporting a script inside SQL Server. You need to look to other choices. First, SQL Server Management Studio can script database. You just right click on a database and select the generate scripts option from the menus. If you do want to automate things, you can look to Powershell to generate a script. Here's an example.

    After that, you're looking at third party tools.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning