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?