I'm running SQL Server 2019 and I need to do manage my backups and logs better.
My main database (mdf) is only 9GB however the log (ldf) is 792GB. I've created back ups of these using SSMS > Tasks > Back up... I was expecting after a back up of the database the logs would reset. As this did not happen against googles advice I tried to shrink the log file, nothing happened.
I've tried setting the max size of the log file to something less, however it won't allow this as the log file is already too big. This is a dev server and very shortly I will be switching this to prod. And so don't currently need historical back ups, but will do once live.
In the meantime I've had to delete other databases and log files to free up space. I've put mdf and ldf on different partitions.
EDIT: I was in Full Recover model however I have now switched this to SIMPLE. I will want point in time in the future but for now this will do. I took a backup however in simple recovery model only full and differential backup types are available, I can not now back up the log. I did both options available, hoping this would reduce the size of the log, it did not.
Question: Now I have a backup, can I just delete the log file and will SQL server create a new one. I can just repeat this process, when the disk fills up?
select name, log_reuse_wait_desc from sys.databasesthat should tell you what's going on and why the log is needed. Also the log file will not shrink after growing automatically, you need to shrink it manually, and it won;t shrink if the log is needed. – Charlieface Mar 09 '22 at 13:37SIMPLEthe server will do automatic checkpoints regularly, so it can be much smaller. Shrink the log file size through SSMS, which will work as long aslog_reuse_wait_descsaysNOTHING. InSIMPLEmode you cannot do a log backup, so you only have the option of a full or diff restore. – Charlieface Mar 10 '22 at 10:30