question

DominiqueDUCHEMIN-4668 avatar image
0 Votes"
DominiqueDUCHEMIN-4668 asked neil-cole answered

Backup MEMCM CD.Latest , Databases etc...

Hello,

I am trying to install the MEMCM 2103 backup using http://thenotoriousdrr.com/index.php/2019/02/01/using-sql-maintenance-plans-to-backup-sccm-cb/

The Site Maintenance Task is failing!!!

Get-ChildItem -Path '\\VRPSCCMMS03\SCCMBackup\UCPBACKUP\CD.latest*.zip' | Where-Object {$_.CreationTime -lt (Get-Date).AddDays(-7)} | Remove-Item | Add-Type -Assembly 'System.IO.Compression.FileSystem' -PassThru | Select -First 1 | % { [IO.Compression.ZIPFile]::CreateFromDirectory('\\VRPSCCMPR01\SMS_UCP\cd.latest', '\\VRPSCCMMS03\SCCMBackup\UCPBackup\CD.latest\CDLatestArchive' + (Get-Date -format 'yyyyMMddHHmm') + '.zip') }


But when doing by powershell the backup works fine but when including it in SQL Agent as a Job it failed
107667-2021-06-21-12-42-11-script-run-failure.png

I check the permissions on the folder, on the share and could not find an issue...
107766-2021-06-21-13-40-00-access-to-cdlatest-folder.png
107767-2021-06-21-13-38-40-access-to-the-share-cdlatest.png


Any idea?

Thanks,
Dom

[3]: /answers/storage/attachments/107781-2021-06-21-13-40-00-access-to-cdlatest-folder.png

mem-cm-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AllenLiu-MSFT avatar image
0 Votes"
AllenLiu-MSFT answered

Hi, @DominiqueDUCHEMIN-4668
Thank you for posting in Microsoft Q&A forum.
I test in my lab, the job runs well.
When you copy the command to SQL Agent as a job, do you add the "powershell.exe -command"?
The command in your SQL Agent Job should like:

 powershell.exe -command "Get-ChildItem -Path '\\VRPSCCMMS03\SCCMBackup\UCPBACKUP\CD.latest\*.zip' | Where-Object {$_.CreationTime -lt (Get-Date).AddDays(-7)} | Remove-Item | Add-Type -Assembly 'System.IO.Compression.FileSystem' -PassThru | Select -First 1 | % { [IO.Compression.ZIPFile]::CreateFromDirectory('\\VRPSCCMPR01\SMS_UCP\cd.latest', '\\VRPSCCMMS03\SCCMBackup\UCPBackup\CD.latest\CDLatestArchive' + (Get-Date -format 'yyyyMMddHHmm') + '.zip') }"


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DominiqueDUCHEMIN-4668 avatar image
0 Votes"
DominiqueDUCHEMIN-4668 answered

Hello,

I moved to a full straight SQL backup and it works so far... so not sure why the internal backup is failing

Thanks,
Dom

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AllenLiu-MSFT avatar image
0 Votes"
AllenLiu-MSFT answered

Hi, @DominiqueDUCHEMIN-4668
Make sure the quotation marks are typed correctly, you may try to retype all the quotation marks.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

neil-cole avatar image
0 Votes"
neil-cole answered

The comments above about using PowerShell.exe - command "YOUR-TEXT-HERE" is correct. BUT. Run it as Type: Operating system (CMDExec), not PowerShell.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.