Author Archives: cviorel - Page 2

Block Chrome Software Reporter Tool

Use the following PowerShell Snippet to disable Chrome Software Reporter Tool from eating your CPU cycles:

ChromeCleanupEnabled’s value determines whether the Software Reporter Tool may run on the system.

ChromeCleanupReportingEnabled’s value determines whether the results are reported to Google.

Enable transmission-daemon logging to file

If you use transmission-daemon on your Raspberry Pi and want to have logs to a file, you can follow a few simple steps to accomplish this:

Edit the service file:

Change the ExecStart line to look like this:

You can choose between these options:

systemctl will complain that the service file was changed. Run:

to reload units.

Create the log file and assign the correct ownership and permissions:

Restart the service:

Have fun!

dbatools – fully automated offsite backups, database restores and integrity checks

In this article you’ll find the process I implemented to test my backups using dbatools and PowerShell.

dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Backed up by a community of passionate people, it will do wonders in your environments.

Requirements:

Now let’s dive a bit into the tasks I wanted to tackle. I needed to:

  1. copy my full backups to a separate location
  2. run daily restores to measure how long it will take me to react in case of a disaster
  3. perform daily integrity checks and still be able to run other maintenance tasks outside business hours (we have big databases > 1TB)
  4. constantly measure how long it takes for each of the above steps to complete
  5. not do all the above manually

Process:

To solve this, I designed the following process (simplified here to show only the interesting parts):

  1. From the Production servers (Server A, Server B, Server C) I run usual full backups on a local drive. That’s done using Ola Hallengren’s MaintenanceSolution. From the C&C (Command and Control) server which has the dbatools module installed, we run remote PS sessions on the Production servers (Server A, Server B, Server C) which are checking for the last full backup using:

    From the output I get the file name which is then copied to Server E (Samba share).
    Once this is done, task 1 is solved.
  2. The C&C server will run a PS remote session to Server D where it will restore the databases directly from the Samba share using:

    With one line of code we are able to restore a bunch of databases, regardless if they were taken using different file paths or on different versions of SQL Server.
    This nails the second task.
  3. During the same session, right after the restores are finished, we trigger integrity checks:

    Task 3 done, two to go!
  4. To measure the elapsed time of that particular command, I use:

    and keep this in a custom PS object.

    I’m writing the data from those custom PS objects to the a database located on the C&C Server.
    Of course, dbatools hadles that for me:

  5. Task 5 is completed with a simple scheduled task on the C&C Server:

From here on I can have reports analyzing all the bits and pieces of my process.
Most important, I know now, how long it takes to restore each database and if indeed my backups are valid.
I’m also able to offload the DBCC CHECKDB outside Production servers.

Conclusion

All this is achieved in under 230 lines of code, with the help of the amazing dbatools PS module.

Adding more servers to the process will mean to just add them in a ServerList.txt file that the script consumes. Simple as that!

Now I have the backups and restores verified without moving a finger! How cool is that?

Thanks dbatools and the wonderful people behind it!

For more awesomeness, check out here the full spectrum of commands dbatools has for you!

 

How to Change your Network Profile in Server 2012R2

Network Profiles were first introduced to allow administrators to configure different firewall profiles based upon what network a user connects to.
Administrators could change the profile by navigating to Network and Sharing Center in control panel and selecting the profile which suits their needs.
In Server 2012, Administrators can no longer change the network profile in Network and Sharing Center, they can view just not change.
You can accomplish this in Power-Shell:
To see the current profile:

To change the profile:

You can do it with a one line command:

Get SMO version on your server

A quick way to find out what SMO versions are installed:

Silently Download and Install SQL Server Management Studio (SSMS)

SSMS is now free and no longer requiring licensing.
It is a separate install and has a more frequent release cycle, usually around 30 days.
To be able to maintain up to date a larger number of SSMS installations I wrote a PowerShell Script for the task.
Of course that a better approach will be to make the download once and then propagate it to other servers, but for now, this works best for me.

Hope you’ll find it useful.

Add syntax color to crontab editor

You might be wondering why you don’t have syntax coloring when you are editing crontab entries.
This can be solved very simply by specifying your editor before starting crontab:

The change can be made persistent across the whole system if you add that line on the /etc/bashrc file.
You you only need this change for certain users only, add the line to their local ~/.bashrc files.

DTExec: The package execution returned DTSER_FAILURE (1)

What to do when a SQL backup job created with SQL server Maintenance Plans fails with this error?

Investigate! No useful information in the logs.
Previously that day I dropped a few unneeded databases so maybe the Maintenance Plan was still referencing them. Everything looked good when the Maintenance Plan was opened in SSMS (it was configured to backup “SELECTED” databases), I could not find any reference to the deleted databases. Under the hood, the Maintenance Plan was still trying to backup those deleted databases because when I clicked OK and then hit Save, that Maintenance Plan was refreshed and everything worked just fine.

So always try to find the root cause.

T-SQL to generate backup and restore commands

Hi guys,

Since my day to day job is a DBA, I figured I will share stuff that others might find useful.
For the first time I will share a small script which will help you generate T-SQL commands in order to script the backup/restore process of your SQL Server.

This was tested on Microsoft SQL Server 2012 (SP1) – Express Edition (64-bit). Feel free to send your comments.

DriveDroid

DriveDroid is an Android application that allows you to boot your PC from ISO/IMG files stored on your phone.
Install it on your android phone and use it to boot any computer.
You can store any number of ISO/IMG files on your SD card.
Nice!