Pregunta

I would like to create a copy of a content database on my UAT machine and restore on my development machine.

The backup of the content db would take abot 12GB. I would like to minimize this size as much as possible.

I don't have SQL management studio on the source machine, so I am wondering, is it possible to create a shrinked and truncated backup of one of the content databases using only powershell?

¿Fue útil?

Solución

It's possible but it's not recommended to Shrink Database log files, instead, you should have a backup log maintenance plan to truncate the Log file periodically.

Read more at THE TRANSACTION LOG FOR DATABASE ‘SHAREPOINT_CONFIG’ IS FULL DUE TO LOG_BACKUP

Regarding the script:

Then run the below command.

$currentData = Invoke-Sqlcmd -serverinstance $SQLInstance -AbortOnError -Query "  
    USE [$dbName]   
    GO   
    DBCC SHRINKFILE (N'$dbLog' , $Size)   
    GO 

You can also check this script Powershell script to truncate SQL log files for one or more SQL databases

Otros consejos

Main thing, do you have white (free ) space inside your database? if yes then you can shrink it and reduce the size other wise shrink will not help. You can try to shrink the logs but it will not give you much as DB size is 12GB.

Note when you pefrom a back of the database logs also shrink-ed automatically.

Shrinking Transaction Logs in PowerShell

In order to reduce the size, you have to clean up your site collections.

  • delete unused documents
  • empty recyclebin
  • if audit logs turned on then trim those.
Licenciado bajo: CC-BY-SA con atribución
scroll top