Thursday, 27 November 2014

Backup Backup Backup

Yup I said it three times, because with backups once is never enough.

For home I take three backups of my files

  • Local direct mirror on a different hard drive in the same PC- if the primary drive fails I have all my files just as there were before.
  • The mirror to a remote site - if the PC dies or is destroyed and takes the primary and secondary drives with it, then I have all my files on a remote site.
  • Local incremental on the same drive as the mirror - if I accidentally delete something, this is where I go to get it back.


All of this isn't perfect, but its a doddle to get working at home and needs pretty much zero management.

Note I'd never rely on this level of backup for a companies data, but this is home, its my data, and how often do you remember to change backup destinations and swap them offsite?

Continue reading after the break on how to set this up

Tuesday, 7 October 2014

Windows 2000 on Hyper-V 2012 R2

So you have a Windows 2000 machine that you really need to keep working even though you know support ended in 2005. It does happen, more often than you think.

You decide to migrate it into a virtual machine and your chosen hyper visor is Microsoft's Hyper-V 2012 R2. This is an excellent platform, not quite as adaptable as VMware, but I really like it.

However your Windows 2000 VM just wont start or install, and its unsupported. Where do you go from here?

Monday, 6 January 2014

TSQL - Timing SQL Queries

Sometimes the best way to narrow down performance issues is just to time the various statement blocks in  TSQL. This little piece of code will do just that for you.

SET STATISTICS TIME OFF--This method allows you to pick when the stopwatch starts and ends which can be more meaningful
--Start the stop watch
DECLARE @Time1 DATETIME, @Time2 DATETIME, @i INT
SELECT
@Time1 = GETDATE(), @i=0--Use this to stop the stopwatchSELECT @Time2 = GETDATE(), @i=@i+1 PRINT 'TIME IS ' + CONVERT(CHAR, @Time2, 14) + ', i = ' + CONVERT(CHAR, @i) + ', TIMEDIFF = ' + CONVERT (CHAR, DATEDIFF(ms, @Time1, @Time2))--Reset the stop watchSET @Time1 = @Time2

TSQL - Generating a number sequence

Handy recursive method to generate a table with a 1-n number sequence

DECLARE @numbers TABLE(
  
num INT);
WITH Nbrs_3( n ) AS ( SELECT 1 UNION SELECT 0 ),
          
Nbrs_2( n ) AS ( SELECT 1 FROM Nbrs_3 n1 CROSS JOIN Nbrs_3 n2 ),
          
Nbrs_1( n ) AS ( SELECT 1 FROM Nbrs_2 n1 CROSS JOIN Nbrs_2 n2 ),
          
Nbrs_0( n ) AS ( SELECT 1 FROM Nbrs_1 n1 CROSS JOIN Nbrs_1 n2 ),
          
Nbrs  ( n ) AS ( SELECT 1 FROM Nbrs_0 n1 CROSS JOIN Nbrs_0 n2 )
      
INSERT INTO  @numbers (num)
      
SELECT n
          
FROM ( SELECT ROW_NUMBER() OVER (ORDER BY n)
                    
FROM Nbrs ) D ( n )
        
WHERE n <= @yourNumberHere

Wednesday, 1 January 2014

VNC, PsTools, remote control mashup

This handy little script uses PsTools (http://technet.microsoft.com/en-gb/sysinternals/bb896649.aspx), default admin shares and various flavours of VNC to allow remote control of a machine on your LAN. Simply run the script, enter your administrator password, the remote machine name or IP and pick a connection option.

View the source after the break