1

I have the following powershell script to backup our sharepoint 2013 on-premises farm + backup the content database + a site collection. as follow:-

Add-PSSnapin "Microsoft.SharePoint.PowerShell" #clear the backup folder data Remove-Item -recurse c:\Backup\* #add new folder to backup the database New-Item -ItemType Directory -Path C:\Backup\contentDB #stop the search service $ssa = Get-SPEnterpriseSearchServiceApplication -Identity "Search Service Application" Suspend-SPEnterpriseSearchServiceApplication -Identity $ssa #backup the farm inside the local c drive Backup-SPFarm -Directory \\servername\Backup -BackupMethod full -BackupThreads 10 -Force #backup the database inside the local c drive Backup-SPFarm -Directory \\servername\Backup\contentDB -BackupMethod Full -Item WSS_Content_ea05119bb8a4408ab450dcd46d6015e8 -force #move the farm backup and the database backup to our file server Move-Item c:\Back\* \\fileserver\intranetbackup\FarmBackUp -Force #backup a site collectio Backup-spsite -identity http:/sitecollection -path c:\Back\site.bak –force #move the backup to our file server Move-Item c:\Backup\* \\fileserver\intranetbackup\ -Force 

but currently when the power-shell script is called from our windows task manager, i have noted that the backup farm and backup database will not complete, and only part of these backup will be moved to our file server, then the site collection will be backuped... so the problem as if this command (Move-Item c:\Back\* \\fileserver\intranetbackup\FarmBackUp -Force) will be reached before the farm backup and the database backup is completed (Backup-SPFarm -Directory \\servername\Backup -BackupMethod full -BackupThreads 10 -Force & Backup-SPFarm -Directory \\servername\Backup\contentDB -BackupMethod Full -Item WSS_Content_ea05119bb8a4408ab450dcd46d6015e8 -force).. so can anyone advice on this please?

1 Answer 1

0

Run each powershell cmdlets one by one, First take backup of SP farm, then SP content DB and at last SP site collection. Use Powershell.exe to execute the script and open it as administrator.

6
  • @Vindor but why i need to separate them ? the flow of the power-shell should be sequential.. is this correct? so the farm & DB backup files should not be moved to our file server using this command Move-Item c:\Back\* \\fileserver\intranetbackup\FarmBackUp -Force unless all the preceding commands has been completed .. is this correct ? Commented Dec 12, 2017 at 9:12
  • correct it is sequential ,but when i face one issue like this it worked after running one by one and making sure the functionality is getting completed. Later moving all the backup files to other location Commented Dec 12, 2017 at 11:11
  • so do you mean to create separate powershell files ?? if so then how i can make sure that first powershell command has been completed before running the second command ? Commented Dec 12, 2017 at 11:34
  • no just open powershell.exe in administrator mode and run one by one and at last use the move-item cmdlets to move the backup files Commented Dec 12, 2017 at 11:37
  • @Vindor i was avoiding do this ,, as it will result in saving all the backups to the server c drive then move them,, this can have the risk of having the c drive full.. Commented Dec 12, 2017 at 12:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.