Powershell + 7zip + SQL Server backups

I needed a way to shrink the backups in SQL Server 2005 (native compression doesn’t exist until the 2008 version). 7zip compresses better than most anything, it’s free (even for commercial use), its stable, and it’s small. Powershell is my favorite tool builder. This is the result:

#set alias to 7zip - adjust path as necessary
set-alias sevenZip "c:\program files\7-zip\7z.exe"

#list of database filenames
$dbdirectories = "db1","db2","db3","db4"

$dbbackupDrive = "x:\"                              # this is where SQL Server stores its backups
$dbzdestination = "y:\7zipped_backups\"             # this is where we will store the 7z version

#Backups location
cd "$dbzdestination"                                # change directory 

#create some file masks based on date

$ybu = get-date (Get-Date).addDays(-1) -format "yyyyMMdd"    # this is the filename mask of yesterday's backups
$yz = get-date (Get-Date).addDays(-1) -format "yyyy.MM.dd"   # this is the filename mask of the zip destination
$yzr = get-date (Get-Date).addDays(-2) -format "yyyy.MM.dd"  # these are the day old 7zips (unused yet)
                                                             # I may want to remove older 7zips after copied offsite

#$exclude1 = "-x!*.dif"                             # unused but could be appended to command
#$exclude2 = "-x!*.7z"                              # unused but could be appended to command 

foreach ($dbdirectory in $dbdirectories)            # looping each db name in our list,
{  

    $backuppath = $dbbackupDrive + $dbdirectory + "\"            #build the path to the backup sources
    $backupfiles = $dbdirectory + "_backup_" + $ybu + "*.*"       #build the filename mask
    $input = $backuppath + $backupfiles                          #full path to source files (SQL Server's files)

    $outputfile = $dbdirectory + "_backup_" + $yz + ".7z"        #build the 7z filename (7zip file)

    cd "$dbzdestination$dbdirectory"               #change the path to the backup destination

    # command line switch descriptions (see http://dotnetperls.com/7-zip-examples)
    #   -t7z = 7zip type
    #   -v10m = split to 10 meg files
    #   -mmt = multithreading

    "7zip a -t7z -v10m -mmt=off $outputfile $input"               # echo out some progress    

    sevenZip a -t7z -v10m -mmt=off "$outputfile" "$input"         # 7zip them up

}

# we're all done, let's cleanup
Remove-Item Alias:sevenZip
Categories: powershell, SQL Server 2005

Bing Maps API (via URLs)

I've located a small page that describes the various functions available via Bing maps.

Categories: Uncategorized

Service Unavailable on SQL Services Reporting Services after Microsoft Patch

Last night, my SSRS server failed on the first access attempt after Multiple Windows patches were installed by WSUS overnight (SQL Server 2005 EE, Windows 2003 SP2). This is not a critical server for me so it doesn't get tested before patches are applied. As such, it gets all patches immediately without testing and, in fact, is a test for such patches for me. Production servers have to be approved by hand after my test servers pass.

Starting off in the Event Viewer > System, I'd see 5 W3SVC warning [a] and followed by a W3SVC failure [b]. Evidently, the rapid fail mechanism in IIS6 was shutting me down.

  • [a] 5 times: Event ID 1009; Source W3SVC; A process serving application pool 'DefaultAppPool' terminated unexpectedly. The process id was 'xxxx'. The process exit code was '0xffffffff'.
  • [b] 1 time: Event ID 1002; Source W3SVC; Application pool 'xxxxxx' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

Restarting application pools would just duplicate the same series of events.

Looking in the Event Viewer > System, I examined which patches were applied overnight

  • KB974318
  • KB973904
  • KB971737
  • KB973917
  • KB974392
  • KB976325-IE8
  • KB955759

KB973917 is 'a non-security update that implements Extended Protection for Authentication in Internet Information Services (IIS).'

After reviewing each knowledge base article, I located a known issue for KB973917 that described my issue perfectly: 'Internet Information Services 6.0 may not function correctly after installing KB973917'. The solution is to reinstall SP2 for your Windows 2003 server. Per Microsoft, 'Reinstalling the KB973917 update should not be necessary'.

If you want to enable the features this update provides, view here: 'http://www.microsoft.com/technet/security/advisory/973811.mspx'

To Microsoft's credit, this is the first patch to cause a problem for me in over 3 years.

Categories: SQL Server 2005, SQL Server Reporting Services

How to install a personal certificate (for email signing) on Windows Mobile 6.1

I wanted to be able to sign/encrypt email on my BlackJack II which is running Windows Mobile 6.1.  I already have the certficates installed in Outlook for the coming year and now I wanted it on my device.

  • Export from Outlook
  • Import certs on WM6.1
    • Restart your phone first
    • Start > All Programs > Applications > File Explorer > Browse to your saved certificates
    • Select your certificate
    • Enter password that was used to export > Done
    • Hopefully, you'll get: "One ore more certificates were installed successfully"
  • View certificates

 

Categories: email, Windows Mobile, Windows Mobile 6.1

Dreamweaver CS3 freezes with code view

My CS3 version of Dreamweaver started freezing on files that were not small when I switched to code view.  Well, the problem is known by Adobe and it relates to time changes (Daylight Savings Time) documented in Adobe KB402776. The article mentions ASP and PHP but my setup is for CFML.

The solution is to remove a file:

path: C:\Documents and Settings\[username]\Application Data\Adobe\Dreamweaver 9\Configuration

filename: WinFileCache-AD76BB20.dat

After closing DW, I just renamed the extension to .dat_old and reopen DW.  Give DW time to recreate it and all should be well again.

Categories: CS3, Dreamweaver

Regular expressions in Visual Studio

Here is a list of regular expressions that work for me in Visual Studio when locating/replacing text in SQL.

  • generate scripts tasks for data will turn dates in to HEX. For example, it will turn a row_created_data column into  CAST(0x000063DF01035C97 AS DateTime). I want to change those dates to GETDATE(): search for ‘CAST\(0x:h AS DateTime\)’ (:h searches for hex values)
Categories: RegEX, Visual Studio

Installing CS4 fails with “Critical errors were found in setup. Please see the Setup log file for details.”

I have CS3 installed already. CS4 refused to install.  Where were these mysterious log files? C:\Program Files\Common Files\Adobe\Installers

Well, the log files are sure thorough!  In fact nothing could jump out as to why it was failing since the logging was so verbose.

The top of the log file has the address for a log analyzer.  That page will install an Adobe Air application which can actually read the logs and link to documents for common failures. Unfortunately, "The module found no solutions to report for the selected log file." 

Categories: Uncategorized

Using RDP (Remote Desktop) is creating Grid Artifacts

Using RDP client on XP SP2 with windows servers (2008, all varieties) was causing a strange grid like pattern.  Installing update KB952155 to the RDP client fixed it.  You can tell if your client is the proper version as the RDP client connection GUI will change to not have a password field on the connection tab after this update is applied.

Evidently, this effect is a side affect after installing KB958470 (MS09-044)

Categories: RDP, Windows Server 2008, Windows XP

Setup new disk on Server 2008 Core

Adding a disk is easy enough when it is a virutal machine.  Making use of the disk with diskpart still has a bit of a learning curve for me.

diskpart

DISKPART> list disk

DISKPART> select disk 1

DISKPART> create partition primary

DiskPart has encountered an error: The media is write protected.
See the System Event Log for more information.

DISKPART> attributes disk
Read-only  : Yes
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No

DISKPART> list disk

  Disk ###  Status      Size     Free     Dyn  Gpt
  ——–  ———-  ——-  ——-  —  —
  Disk 0    Online        36 GB      0 B
* Disk 1    Offline      127 GB   127 GB

DISKPART> attributes disk clear readonly

Disk attributes cleared successfully.

DISKPART> online disk

DiskPart successfully onlined the selected disk.

DISKPART> convert dynamic

DiskPart successfully converted the selected disk to dynamic format.

DISKPART> create volume simple

DiskPart successfully created the volume.

DISKPART> list disk

  Disk ###  Status      Size     Free     Dyn  Gpt
  ——–  ———-  ——-  ——-  —  —
  Disk 0    Online        36 GB      0 B
* Disk 1    Online       127 GB      0 B   *

DISKPART> list part

  Partition ###  Type              Size     Offset
  ————-  —————-  ——-  ——-
  Partition 1    Dynamic Data       127 GB    32 KB

DISKPART> list vol

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ———-  —  ———–  —–  ———-  ——-  ———  ——–
  Volume 0     E   20081030_12  CDFS   DVD-ROM      342 KB  Healthy
  Volume 1     C                NTFS   Partition     36 GB  Healthy    System
* Volume 2                      RAW    Simple       127 GB  Healthy

DISKPART> format fs=NTFS label="FTP data"

  100 percent completed

DiskPart successfully formatted the volume.

DISKPART> assign letter=d

DiskPart successfully assigned the drive letter or mount point.

DISKPART> list vol

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ———-  —  ———–  —–  ———-  ——-  ———  ——–
  Volume 0     E   20081030_12  CDFS   DVD-ROM      342 KB  Healthy
  Volume 1     C                NTFS   Partition     36 GB  Healthy    System
* Volume 2     D   FTP data     NTFS   Simple       127 GB  Healthy

 

Categories: Windows Server 2008 server core

Enable remote management to 2008 Server Core

It seems Microsoft's guys think that when a server is added to a domain (DOMAIN JOINED), no configuration is necessary but it was in my case:

  • netsh advfirewall firewall set rule group="Remote Administration" new enable=yes
Categories: Windows Server 2008 server core

Proudly powered by WordPress Theme: Adventure Journal by Contexture International.