Sunday, June 9, 2024

Backup website and database via script part-2

Hello everyone,

As I stated in my previous blog post, we can take website and SQL backups more easily if we properly accumulate website and database backup scripts.

We can take it step by step to do this. To start, we make a single batch file that will run the website backup script in addition to the SQL backup. Kindly adjust the settings to suit your particular surroundings.

Make a backup.bat file with the following code in it:


sqlcmd -S ServerName -U sa -P Sitecore@123 -v path = "'C:\Personal\backup\'" -i "website backup.sql"
"C:\Program Files\7-Zip\7z.exe" a -tzip "C:\Personal\backup\DB_%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%.zip" "C:\Personal\backup\sc93local_*.bak"
del "C:\Personal\backup\sc93local_*.bak"

@pause
PowerShell -File "C:\Personal\Tricks\website backup with exclude folder.ps1"

@pause

It will be simpler to identify the backup with a date if you follow the method mentioned above, which generates a backup datewise.

The powershell script that makes a backup of the website is targeted by the lower portion of the batch file.

You can go to this github link for the modified scripts that I changed correctly for the database backup ("website backup.sql") and the website backup ("website backup with exclude folder.ps1").

 

I hope you enjoy this Sitecore blog. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this article if it’s useful for you.

No comments:

Post a Comment