Skip to main content
spelling
Source Link
toryan
  • 335
  • 2
  • 3
  • 7

We have a daily task to overwrite a number of development databases using backups of the associated production databases. The backups are produced by maintenance plans on the production server then transferred to the dev server by FTP. Each day we run a SQL statement similar to this to overwrite each database:

RESTORE DATABASE [Database1] FROM DISK = N'D:\path\to\Database1_backup_2015_02_05_190004_7401803.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO 

Each time we run this we have to replace the file name with the correct most recent file. I would like to automate this somehow to minimise the chance of operator error. The problem is that we can't control the name of the .bak file (although the format is consistent - database name, date, time and whatever thanthat seven digit number is), and the folder will usually contain several days worth of backups.

We have a daily task to overwrite a number of development databases using backups of the associated production databases. The backups are produced by maintenance plans on the production server then transferred to the dev server by FTP. Each day we run a SQL statement similar to this to overwrite each database:

RESTORE DATABASE [Database1] FROM DISK = N'D:\path\to\Database1_backup_2015_02_05_190004_7401803.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO 

Each time we run this we have to replace the file name with the correct most recent file. I would like to automate this somehow to minimise the chance of operator error. The problem is that we can't control the name of the .bak file (although the format is consistent - database name, date, time and whatever than seven digit number is), and the folder will usually contain several days worth of backups.

We have a daily task to overwrite a number of development databases using backups of the associated production databases. The backups are produced by maintenance plans on the production server then transferred to the dev server by FTP. Each day we run a SQL statement similar to this to overwrite each database:

RESTORE DATABASE [Database1] FROM DISK = N'D:\path\to\Database1_backup_2015_02_05_190004_7401803.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO 

Each time we run this we have to replace the file name with the correct most recent file. I would like to automate this somehow to minimise the chance of operator error. The problem is that we can't control the name of the .bak file (although the format is consistent - database name, date, time and whatever that seven digit number is), and the folder will usually contain several days worth of backups.

added 2 characters in body; edited title
Source Link
marc_s
  • 9.1k
  • 6
  • 46
  • 52

Automatically restore MSSQLSQL Server database from file from another server

We have a daily task to overwrite a number of development databases using backups of the associated production databases. The backups are produced by maintenance plans on the production server then transferred to the dev server by FTP. Each day we run a SQL statement similar to this to overwrite each database:

RESTORE DATABASE [Database1] FROM DISK = N'D:\path\to\Database1_backup_2015_02_05_190004_7401803.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO 

Each time we run this we have to replace the file name with the correct most recent file. I would like to automate this somehow to minimise the chance of operator error. The problem is that we can't control the name of the .bak.bak file (although the format is consistent - database name, date, time and whatever than seven digit number is), and the folder will usually contain several days worth of backups.

Automatically restore MSSQL database from file from another server

We have a daily task to overwrite a number of development databases using backups of the associated production databases. The backups are produced by maintenance plans on the production server then transferred to the dev server by FTP. Each day we run a SQL statement similar to this to overwrite each database:

RESTORE DATABASE [Database1] FROM DISK = N'D:\path\to\Database1_backup_2015_02_05_190004_7401803.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO 

Each time we run this we have to replace the file name with the correct most recent file. I would like to automate this somehow to minimise the chance of operator error. The problem is that we can't control the name of the .bak file (although the format is consistent - database name, date, time and whatever than seven digit number is), and the folder will usually contain several days worth of backups.

Automatically restore SQL Server database from file from another server

We have a daily task to overwrite a number of development databases using backups of the associated production databases. The backups are produced by maintenance plans on the production server then transferred to the dev server by FTP. Each day we run a SQL statement similar to this to overwrite each database:

RESTORE DATABASE [Database1] FROM DISK = N'D:\path\to\Database1_backup_2015_02_05_190004_7401803.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO 

Each time we run this we have to replace the file name with the correct most recent file. I would like to automate this somehow to minimise the chance of operator error. The problem is that we can't control the name of the .bak file (although the format is consistent - database name, date, time and whatever than seven digit number is), and the folder will usually contain several days worth of backups.

Source Link
toryan
  • 335
  • 2
  • 3
  • 7

Automatically restore MSSQL database from file from another server

We have a daily task to overwrite a number of development databases using backups of the associated production databases. The backups are produced by maintenance plans on the production server then transferred to the dev server by FTP. Each day we run a SQL statement similar to this to overwrite each database:

RESTORE DATABASE [Database1] FROM DISK = N'D:\path\to\Database1_backup_2015_02_05_190004_7401803.bak' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10 GO 

Each time we run this we have to replace the file name with the correct most recent file. I would like to automate this somehow to minimise the chance of operator error. The problem is that we can't control the name of the .bak file (although the format is consistent - database name, date, time and whatever than seven digit number is), and the folder will usually contain several days worth of backups.