We are planning to create c# jobs that perform some database maintenance actions such as backup, shrink files etc...
I have read in many blogs that database shrink is not recommended and thats why I'm posting here in order to have some recommendations to this topic.
We want also to rebuild / reorganize the indexes. This is an easy one and I already wrote the C# script for it.
The backup for the databases and shrink for the transactions log should be also done. The databases have recovery model: Full.
Some blogs recommend this order:
- Backup the database
- Change recovery model
- Shrink the .ldf file
- Re-set the original recovery model
some others recommend this not to do shrink at all, are to use recovery model: simple.
My questions are:
- How often should we rebuild or reorganize indexes in the sql tables?
- Is shrink for log files a good idea?
- In which order should we do the database backup / logs backup / logs shrink?
I don't have enough DBA experience, so it will be great if you can give me some hints.