If I were to backup 50 databases in SQL server, I want to make sure that backup is taking place when the server is not that busy. Is there any way or script/tool to use to check when the server is not being heavily used?
With respect to backing up in always on availability groups, If I do my backups in my secondary replica, the log files in my primary replica will continue to grow big since it doesn't get truncated coz the log is not backed up in the primary replica. How can we avoid that issue with the log backup on the primary replica? Is it possible to do the full backups on the secondary replica and log backups on the primary replica to avoid the log in the primary replica growing too big? Will it work if we restore the database?
I will answer your second question.
If I do my backups in my secondary replica, the log files in my primary replica will continue to grow big since it doesn't get truncated coz the log is not backed up in the primary replica
NO, this is where Availability Groups are so nice. No matter on which secondary replica you take transaction log backup it would work. What happens is when you take backup on secondary replica and after it finishes the secondary replica will give all information related to log backup to primary replica like LSN and VLF's that can be marked as truncated and accordingly primary replica does the changes. Bottom line is you can take log backup on any replica and the changes would be reflected on primary.
I would suggest you read Active Secondaries: Backup on Secondary Replicas (AlwaysOn Availability Groups). From the BOL I quote
A consistent log chain is ensured across log backups taken on any of the replicas (primary or secondary), irrespective of their availability mode (synchronous-commit or asynchronous-commit).
So you can see you can take transaction log backup on any replica no matter whether it is synchronous or asynchronous replica.
Is it possible to do the full backups on the secondary replica and log backups on the primary replica to avoid the log in the primary replica growing too big? Will it work if we restore the database?
Yes you can take full backup on secondary replica but you have to make sure that they are COPY_ONLY full backups. As already pointed in BOL article shared above.
Backup Types Supported on Secondary Replicas
•BACKUP DATABASE supports only copy-only full backups of databases, files, or filegroups when it is executed on secondary replicas. Note that copy-only backups do not impact the log chain or clear the differential bitmap.
•Differential backups are not supported on secondary replicas.
Please note that the backup history is kept in the msdb database of the replica the backup got executed on. This implies that backup history and chain cannot be retrieved out of one instance only.
Differential backup can only be done on instance which is primary node.
Restore will work as normal but I must tell you cannot just restore database which is part of availability group you need to first evict it out of AG and then perform the restore.
At last I suggest you to read MSDN blog series on Availability Groups backup and restore by SQLGardner for more details
If you are backing up lot of big databases it does create lot of I/O so your idea to configure backup when load is relatively very less is correct. Normally during midnight or during maintenance windows load is relatively very less you can physically look at server to see the load and configure backup at that time.
SQL Server backups are designed to be low impact and don't generally affect running systems.
A correct backup and restore strategy takes into account a lot more than "when the server is not busy". A few examples:
- What is the business RTO and RPO for each of the 50 databases
- What is the DR expectation generally?
- What about log backups? These need to run regularly at sort intervals
Unless of course you are doing something wrong like using one disk for everything, but then you have bigger problems.
- How can I backup a large SQL Server database without impacting performance?
Note: Part 2 was added while I answered so did not see it