SQL Express – Backup Plan

SQL express doesn’t have the luxury of SQL maintenance plans, but you can still write a SQL script to dump a database to a particular location and run it via task scheduler on a daily basis.

Create SQL query and save it to a particular location… (NightlyBackup.sql)

DECLARE @pathName NVARCHAR(512)

SET @pathName = ‘D:\SQL Backup\database_‘ + Convert(varchar(8), GETDATE(), 112) + ‘.bak’

BACKUP DATABASE [database] TO DISK = @pathName WITH NOFORMAT, NOINIT, NAME = N’db_backup’, SKIP, NOREWIND, NOUNLOAD, STATS = 10

Create cmd / bat and save to similar location to above… (Backup DB to disk.cmd)

sqlcmd -S servername\INSTANCENAME -U sqluser -P sqluserpassword -i “NightlyBackup.sql”

forfiles /p “C:\SQLBackupLocation” /m *.bak /s /d -2 /c “cmd /c del @file : date >= 7 days >NUL”

Create windows task schedule event to run above at 5:30pm everyday. 

ERROR: No forward-proxy ports configured

I had the above issue after a squid upgrade and after changing from http_port 3128 transparent to http_port 3128 intercept.

Add “http_port 8080” line to squid.config to avoid this message, if you are not already using that port.

The changes in security require that a separate port be setup for forwarding proxy requests

nginx – and gzip

i only have vdsl at home and host my website via it… the following graphs shows when nginx started serving faster than the vdsl connection could handle (which is about 9Mbits)

ngnix with cache enabled, gzip enabled and set to 6

http://loadimpact.com/load-test/sigtar.com-6a246200e28f354c64582cf2c0b6ce46

ngnix with cache enabled, gzip enabled and set to 9 (maximum)

http://loadimpact.com/load-test/sigtar.com-1422b3e7250c4e3acb7868177f2b2056

ngnix with cache disabled, gzip enabled and set to 9 (maximum)

http://loadimpact.com/load-test/sigtar.com-19561e7422e24f35fb557c662d20beac

 

setup vmware environment

vmwareOne of the scripts i use to standardise our vmware host deployments;


# Author : Darren T
# v1 : Setup vcenter parameters
# Usage ;
# Please manually connect to vCenter, use "Connect-VIServer" -- this promotes usernames and passwords not being saved with script.
# Modify Variables below before running.
# ------------------- VARIABLES -------------------------
# Database Retention Policy
$Days_Retension = "30"
# Set SMTP Server & Sender Account
$SMTP_Server = "192.168.9.10"
$Sender_Account = "administrator@company.co.nz"
# ------------------- CODE ONLY BELOW -------------------
# Database Retention Policy -- Enable limits
# Get-AdvancedSetting -Entity $defaultVIServer | where {$_.Name -match "^task.|^event."}
Write-Host "Setting Database Retension... " -NoNewLine;
Get-AdvancedSetting -Entity $defaultVIServer -Name "event.maxAge" | Set-AdvancedSetting -Value $Days_Retension -Confirm:$false
Get-AdvancedSetting -Entity $defaultVIServer -Name "event.maxAgeEnabled" | Set-AdvancedSetting -Value $true -Confirm:$false
Get-AdvancedSetting -Entity $defaultVIServer -Name "task.maxAge" | Set-AdvancedSetting -Value $Days_Retension -Confirm:$false
Get-AdvancedSetting -Entity $defaultVIServer -Name "task.maxAgeEnabled" | Set-AdvancedSetting -Value $true -Confirm:$false
# Set SMTP Server & Sender Account
Write-Host "Setting SMTP Server & Sender Account... " -NoNewLine;
Get-AdvancedSetting -Entity $defaultVIServer -Name "mail.smtp.server" | Set-AdvancedSetting -Value $SMTP_Server -Confirm:$false
Get-AdvancedSetting -Entity $defaultVIServer -Name "mail.sender" | Set-AdvancedSetting -Value $Sender_Account -Confirm:$false

nginx – setup as reverse proxy

 

Previously to take down this wordpress site all you needed to do was hold down F5 for about 20 seconds then the site would take about 5 mins to recover.

There were a few factors causing this and quite a few different methods to solving the problem. WordPress itself is run on php / apache, apache has an evasive mod which can block certain IPs depending on the defined abusive behavior (typical DDOS attack). Since i like to run a few websites behind a single IP i looked at fixing the issue closer to the perimeter….

Enter nginx (engine x) as a reverse proxy, the site now typically caches all content and serves it straight out of memory. No longer does mysql / apache kill itself under high load on the backend…

nginx

You will need to create the nginx directories if they dont already exist. Check /var/log/nginx/error.log (default ubuntu) if any issues starting the service.

sudo aptitude install nginx
sudo service nginx start

The following added to http {}
(located in /etc/nginx/nginx.conf)


log_format cache '***$time_local '
'$remote_addr '
'$upstream_cache_status '
'Cache-Control: $upstream_http_cache_control '
'Expires: $upstream_http_expires '
'"$request" ($status) ';
access_log /var/log/nginx/access.log cache;
error_log /var/log/nginx/error.log;
server_names_hash_bucket_size 64;
proxy_cache_path /var/www/nginx_cache levels=1:2
keys_zone=one:10m
max_size=1g inactive=30m;
proxy_temp_path /var/www/nginx_temp;

the following added to location / {}
(located in /etc/nginx/sites-enabled/default)


proxy_pass http://sigtar;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering on;
proxy_buffer_size 16k;
proxy_buffers 32 16k;
proxy_cache one;
proxy_cache_valid 200 302 304 10m;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
client_body_buffer_size 128k;
proxy_busy_buffers_size 64k;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;

Note if you have problems with wordpress redirect issues… check this post;

http://tommcfarlin.com/resolving-the-wordpress-multisite-redirect-loop/

Also confirm you have this line in http {}

server_names_hash_bucket_size 64;

Very basic load test, user load time is reasonably consistent as user count increases.
http://loadimpact.com/load-test/sigtar.com-ad07b7870a75c854a935752b0a032c53

load test

activate windows from command line – slmgr

Temporarily extend evaluation period (limited execution – see output below)…

C:\Windows\System32>cscript slmgr.vbs /rearm

C:\Windows\System32>shutdown -r -t 1

Show detailed license information…

C:\Windows\System32>cscript slmgr.vbs /dlv

License Status: Initial grace period
Time remaining: 43200 minute(s) (30 day(s))
Remaining Windows rearm count: 0

Activate windows…

C:\Windows\System32>cscript slmgr.vbs /ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx

C:\Windows\System32>cscript slmgr.vbs /ato

Will require access to the internet – most of the time the issues are either time sync or connectivity to internet.

http://support.microsoft.com/kb/921471 Windows activation fails and may generate error code 0x8004FE33

To do this, configure the following list of CRLs to be unauthenticated on the proxy server:
http://go.microsoft.com/
https://sls.microsoft.com/
https://sls.microsoft.com:443
http://crl.microsoft.com/pki/crl/products/MicrosoftRootAuthority.crl
http://crl.microsoft.com/pki/crl/products/MicrosoftProductSecureCommunications.crl
http://www.microsoft.com/pki/crl/products/MicrosoftProductSecureCommunications.crl
http://crl.microsoft.com/pki/crl/products/MicrosoftProductSecureServer.crl
http://www.microsoft.com/pki/crl/products/MicrosoftProductSecureServer.crl
https://activation.sls.microsoft.com

Active Directory- redirect default Containers to Organisational Units

One really useful tidbit I picked up last week –

Redirusr & redircmp

Configures the default OU for computers and users so they don’t appear in the default containers when they are added (effectively meaning they only get root domain policies).

As you would guess – it helps keep the default AD containers clean by placing machines straight into an OU and also applying any policies attached.

 

windows 2012 change key from evaluation to standard

get current version;

dism /online /get-currentedition

Deployment Image Servicing and Management tool
Version: 6.2.9200.16384

Image Version: 6.2.9200.16384

Current edition is:

Current Edition : ServerStandardEval

dism /online /set-edition:ServerStandard /ProductKey:xxxxx-xxxxx-xxxxx-xxxxx-xxxxx /AcceptEula

Deployment Image Servicing and Management tool
Version: 6.2.9200.16384

Image Version: 6.2.9200.16384

Starting to update components…
Starting to install product key…
Finished installing product key.

Removing package Microsoft-Windows-ServerStandardEvalEdition~31bf3856ad364e35~amd64~~6.2.9200.16384
[==========================100.0%==========================]
Finished updating components.

Starting to apply edition-specific settings…
Finished applying edition-specific settings.

The operation completed successfully.
Restart Windows to complete this operation.
Do you want to restart the computer now? (Y/N)

note : you must change evaluation edition to standard before promoting to a domain controller. you cannot change a DC in eval mode to standard and are forced to demote the server before changing the edition.

windows 2012 – dedup

If you have some archive data that you would like to copy onto a  win 2012 server, but dont know how to estimate the end volume size (if VM etc). Start small – about 1/2 of the total capacity of the drive. Robocopy the data onto the drive until nearly full, manually run dedupe, wait until complete, continue robocopy, repeat and rinse. There will be occasions where you will run out of disk space at that point its time to extend your disk.

You will need to enable deduplication on the file server, either hit the GUI or use the following to enable the module;

Import-Module ServerManager
Add-WindowsFeature -name FS-Data-Deduplication

The powershell commands that you’ll use;

Enable-DedupVolume E:
(enables E drive for deduplication)

Set-DedupVolume E: -MinimumFileAgeDays 0
(default is 5 days – which may be sufficient for achival type files)

Start-DedupJob E: –Type Optimization
(manually starts dedup on E drive)

Get-DedupJob
(shows status of currently running dedup and scheduled dedup jobs)

I have used the following powershell script to continually run the dedup process on my archive drive (during migration work). Checks if dedup processes are running – if not execute dedup on archive drive.


cls
$x = 1
while ($x = 1)
{
$dedupcheck = Get-Dedupjob | Out-String;
if ($dedupcheck -eq "") {
echo "starting dedup process on F drive";
Start-DedupJob F: -type Optimization;
};
echo "dedup jobs running - sleeping for 2 min";
sleep 120;
echo "";
get-dedupstatus;
echo "";
}

Equallogic – 6.0 Feature List

http://www.dell.com/learn/us/en/04/campaigns/equallogic-software

Features introduced in release 6.0:

• Synchronous Replication
• Snapshot Space Borrowing
• Volume Unmap
• Volume Undelete
• Support for SED drives and IPsec

Features you have come to rely on:

• Data Center Bridging
• Automatic load balancing
• VMware® Thin Provisioning awareness
• Auditing of administrative actions
• Microsoft® Active Directory integration
• Peer storage architecture
• Rapid provisioning
• Storage pools
• Roles-based administration
• Thin clones
• SAN Data Copy Offload
• SAN Zero Offload and Scalable Lock Management for VMware
• Intelligent tiering of data across models that combine solid-state drive (SSD) and hard drives
• Integration with the VMware® vStorage APIs
• Nondisruptive array upgrades
• Nondisruptive array removal
• Online data and volume movement
• Automatic RAID placement
• Thin provisioning
• Instant volume restore
• Multivolume, writable snapshots
• Snapshot and point-in-time replication scheduler
• Volume cloning
• Volume consistency sets
• Auto-start disk monitoring system
• Email home
• Enclosure monitoring system
• Performance monitoring