1

These documentation articles

https://learn.microsoft.com/en-us/sql/linux/tutorial-restore-backup-in-sql-server-container?view=sql-server-2017

and

https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-backup-and-restore-database?view=sql-server-2017

Tell us how to restore individual databases. I want to restore all databases in the file list. Is there a way to do this programmatically from within the sqlcmd without involving bash?

2
  • Have you checked - dbatool.io ? Its powershell based and works mostly cross platform as well.
    – Kin Shah
    Commented Sep 12, 2019 at 21:24
  • dbatools.io –No, I haven't. I don't think project teammates would go for installing pwsh in this instance. I'm running on Debian and hoping for a SQL-only solution, if one exists. In other words pwsh isn't really any better than bash. Commented Sep 13, 2019 at 0:08

1 Answer 1

1

Based on what you want I would do the following:

  1. Create two files - List.txt (with the list of DBs you want to restore) and DBRestore.bat with sqlcmd command to run a stored procedure 'DBRestore' inside SQL Server
  2. Create a stored procedure 'DBRestore' which loads into SQL Server temp table the list from the LIST.txt and processes it - reads DB name one by one and restores them

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.