There is a production database ~1T, and ~200GB of log file unused space, simple recovery mode. I want it to restore at test environment and get rid of those 200GB log file to free up space for other DBs restores. What I tried:
- Backup DB at production
- Kill connections and restore DB (with recovery and replace) at test target VM
- Clean up replication of restored database
- Shrink DB
DBCC SHRINKFILE (N'MyLogFile',1)of restored database
The process above is automated, so I can't run many checks during the process.
The step 4 fails with an error:
Cannot shrink log file 2 (MyLogFile) because the logical log file located at the end of the file is in use.
Questions:
- Can this be because the database has transactional replication enabled, although I clean up replication at step 3.
- Do I actually need shrink of the logs, may would be enough just leave it after restored, and simple recovery mode checkpoints will do log backups (and decrease log file unused space) automatically?