Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, August 4, 2016

Script for restoring Sitecore databases on DEV, QA and UAT environment



There are some task which are very important but takes time during website development and maintenance. One such task is restoring databases.

After every SPRINT, I have to take backup of Production Sitecore master and web databases and need to restore on Staging, QA and DEV environment. The size of each database is 12 GB ;)

This tasks are very time consuming where one need to wait for SQL server response and complete the restoration process of such a huge database.

I thought that instead of doing this restoration from SQL Server management studio, let’s try with SQL query.

I found a great script on http://blog.sqlauthority.com/ .

There are 4 steps involved with this restoration query

1. Find the Logical name of data and log file from database backup file

RESTORE FILELISTONLY FROM DISK = 'D:\Backup\TestSitecore_Core_20160112014154.BAK'
GO

2. If you are going to restore on existing database, then run below query for making database to single user mode. If you are going to restore as a new database then skip this query 

-- Restore to an existing database
-- Make Database to single user Mode
ALTER DATABASE TestCoreDB1 SET SINGLE_USER WITH ROLLBACK IMMEDIATE

 3. This is the main query which restore below CORE database.

-- Restore Database
RESTORE DATABASE TestCoreDB1
FROM DISK = N'D:\Backup\TestSitecore_Core_20160112014154.BAK'
WITH  REPLACE, RECOVERY, 
MOVE N'Sitecore.Core.Data' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\TestCoreDB1_01Aug.mdf', 
MOVE N'Sitecore.Core.Log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\TestCoreDB1_01Aug.ldf'
GO

Where Sitecore.Core.Data and Sitecore.Core.Log is the logical name returned by first query.

4. Skip this query if you have restored file for a new database or if no error occurred in step 3.

Run this query only if your database goes into single user mode or any error occurred. This query will set the database on multi user mode.

/*If there is no error in statement before database will be in multiuser
mode. If error occurs please execute following command it will convert database in multi user.*/
ALTER DATABASE TestCoreDB1 SET MULTI_USER
GO

That’s it. This script make my life easy and in all DEV, QA and UAT environment, every time I just need to change the database name and backup file path. Rest of the things are taking care by script.

Knowledge of SQL server and its trick can make Sitecore guy and of course gals life easy.

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

Monday, August 1, 2016

How to monitor and generate report of different server activities



You need to monitor servers of your hosting environment. 

Especially in production environment you want to monitor website hosted server, database server, SOLR server, manogoDB server or any other server.

You may need to generate and mail daily utilization reports of these servers to client or technical team.

So what are the ways to monitor your server activities?

Solution: 

OpManager is great tool to monitor activities of your servers. There are lots of features provided by OpManager tool.

One such feature is to generate different type of reports like Daily, monthly Server Memory Utilization report etc.

This article covers step to generate different reports from OpManager

·         Login to system where OpManager is installed
·         Double click shortcut icon “ManageEngine OpManager” from Desktop or get it from Start menu
·         This open http://localhost:9000/ webpage in browser. In our case Opmanager is running as local site on port number 9000
·         Login to site
·         Click on Reports located at bottom left side of webpage as marked in red rectangle in below image
·         Opmanager provides different default report as per industry needs
·         Choose one of the report category like "Health and Performance" link as marked in red rectangle in below image
·         Mostly we need to generate and share report with client such as Devices by CPU utilization, Devices by Memory utilization, Devices by Disk utilization etc.
·         Click on any one of the available report type such as "Device by CPU utilization" link as marked in red rectangle in below image





·         Click on “Edit Report” button
·         You can choose different option from Edit Report window such as devices category, period, time window etc. Choose below option for generating monthly report





·         Click on Show Report button.
·         You can Export generated report to PDF, excel etc.
 
Please leave your comments or share this tip if it’s useful for you.

Friday, July 22, 2016

Whitepaper : All about customizing workflow in Sitecore


In almost all the Sitecore projects, developers have to create, sometimes customize and need to apply workflow to items. This guide covers all the possible scenarios and customization technics with code used for workflow. This whitepaper covers 

1.    What is workflow
2.    Create Editor and Reviewer Roles
3.    Assign permissions on items to roles
4.    Create editor and reviewer users
5.    Map users with roles
6.    Create individual/group reviewer items in content tree
7.    Create Custom comment window
8.    Apply validation rules on comment windows field
9.    Create Custom workflow
10. Apply custom workflow on items
11. Customizing workbox
12. Sorting items in Awaiting Approval section in Workbox
13. Show items associated to particular editor in draft section
14. Complete code for customizing workbox
15. Customizing items comments in Awaiting Approval section
16. Test all the scenarios

I tried my best to include all the scenarios that are associated with Sitecore Workflow.


You can download this guide from here.

You can read this white paper from here:

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