dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
I wasn't asked for a key!
//A
Using custom performance charts with a custom time range can cause the vSphere Client session connected to vCenter server to stop responding and consume 100% of one client logical CPU. For information about using custom performance charts refer to Customize Advanced Chart Views section from the vSphere Datacenter Administration Guide.
The vSphere client log may show these errors:
SSL Validation failed in WebRequestPatch.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.21.xx.xx:8443
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at VirtualInfrastructure.Utils.WebRequestPatch.PreAuthSSL(HttpWebRequest request, Uri uri)
SSL Validation failed in WebRequestPatch.
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.21.xx.xx:8443
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at VirtualInfrastructure.Utils.WebRequestPatch.PreAuthSSL(HttpWebRequest request, Uri uri)
Invoke 67 Start WaitForUpdates on PropertyCollector:propertyCollector [xx.vmware.com].
Initial socket creation and SSL authentication failed:
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 10.21.xx.xx:8443
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at VpxClient.Plugins.WebBrowserProxy.RedirectBrowser()
Invoke 67 Finish WaitForUpdates on PropertyCollector:propertyCollector [xx.vmware.com] - Serial:0.002, Server:018.225
Note: For the location of vSphere client logs, see Common vCenter Server and vSphere Client Windows paths (1028185).
VMware is aware of this issue and is working on a fix to resolve this issue.
However, you can workaround this issue by clearing the custom performance chart from the client, and avoid using a custom start time on a whole round hour (e.g. 1:00, 2:00, 3:00...).
To delete the custom chart information from the vCenter client:
The <VS host>-charts.xml file contains the custom chart data.
This file can be deleted completely if this is the only custom chart
or
You can edit the file to retain other custom charts:
Note: This article assumes that you are familiar with XML concepts and that you have made adequate backups before proceeding.
(Get-Host).ui.rawUI.Foregroundcolor = "green"
(Get-Host).ui.rawUI.Backgroundcolor = "black"
(Get-Host).ui.rawUI.WindowTitle = "The Power of the Shell"
Add-PsSnapin Microsoft.Exchange.Management.PowerShell.Admin -ErrorAction SilentlyContinue
Add-PSSnapin VMware.VimAutomation.Core
To test it type cls then get-snapin and you should see the VMware snapin preloaded.
Just a quickie:
Been a while since my last post (about a year!), but that’s what happens when you venture off into the hills of Exchange…
Anyway, I thought I’d put this one up as I reminder to myself as much as anything else. The web client is kind-of-cool:
This error may appear when you try to run the discovery process using the Xenapp6 evaluation VHD. I was using the VHD on Hyper-V and decided to change over to VMWare VSphere. I managed to convert the virtual machine to be used on VMWare (using the Standalone Converter http://downloads.vmware.com/d/info/infrastructure_operations_management/vmware_vcenter_converter_standalone/5_0). That worked fine but the problems started when trying to use XenApp 6 on a VM hosted on Vsphere. I tried using the local Administrator account (the one used to create the original image) but could not run the discovery process using Citrix Delivery Services Console. I then tried this:
Attempting to connect to the data store with new configuration settings.
Successfully connected to the data store.
Configuration successfully changed.
Please restart the IMA Service for changes to take effect.
If you need to change the administration account (Admin) for Citrix XenApp 6, try the following steps:
I had a problem installing XenApp Fundamentals. During the installation process I received an installation error that indicated that the installation had failed and that I should check the ‘Citrix Access Essentials Install Log.txt’
I presumed that installing the program on Server 2008 R2 would be enough. However the setup that finally worked for me was as follows:
If you follow the above procedure, you should be OK. Also when applying a licence, make sure that the name you use is matches the NetBIOS name of the server (case-sensitive).
Quite simple really. I have found that in certain situations, (help in backup) I have needed to delete databases (perhaps several databases exist on a single drive). You can move mailboxes from one database to another simply by typing the following cmdlet:
[PS] Get-Mailbox –Database TheDatabaseID | New-MoveRequest –TargetDatabase TheDatabaseID
Now this will move the ‘regular’ mailboxes but not those marked as arbitration mailboxes. You can identify those by using the following:
[PS] Get-Mailbox –Database TheDatabaseID –Arbitration
Now you know what mailboxes to look out for, move them to the database of preference.
[PS] Get-Mailbox –Database TheDatabaseID –Arbitration | New-MoveRequest –TargetDatabase TheDatabaseID.
And then check that the arbitration mailboxes have been moved to an alternative database. You can also check out the move requests themselves:
[PS] Get-MoveRequest
Now that the mailboxes (hidden ones included) have been moved, try deleting the database now. It should work but remember that you will still have to remove the database files manually.
For Matt and Mark!
The setting is set per server. You can determine the value on your server by typing the following cmdlet:
[PS] Get-MailboxServer | FL Name,AutoDatabaseMountDial
MountDial determines if a passive copy of a DAG can automatically come online based on how many log files being copied to it. If you run the above command, you will see one of several values for AutoDatabaseMountDial including:
These mean the following:
BestAvailability
If you specify this value, the database automatically mounts immediately after a failover if the copy queue length is less than or equal to 12. The copy queue length is the number of logs recognized by the passive copy that needs to be replicated. If the copy queue length is more than 12, the database doesn't automatically mount. When the copy queue length is less than or equal to 12, Exchange attempts to replicate the remaining logs to the passive copy and mounts the database.
GoodAvailability
If you specify this value, the database automatically mounts immediately after a failover if the copy queue length is less than or equal to six. The copy queue length is the number of logs recognized by the passive copy that needs to be replicated. If the copy queue length is more than six, the database doesn't automatically mount. When the copy queue length is less than or equal to six, Exchange attempts to replicate the remaining logs to the passive copy and mounts the database.
Lossless
If you specify this value, the database doesn't automatically mount until all logs that were generated on the active copy have been copied to the passive copy.
BestEffort
This will mount no matter the copy queue length. Be careful with this setting as you could loose a lot of mailbox data!
To manually switch from passive to active type the following cmdlets:
[PS] Move-ActiveMailboxDatabase DB4 -ActivateOnServer MBX3 -MountDialOverride:None
As the MountDialOverride property is set to ‘none’ whatever is currently set (probably the default) remains.
The default on my server is GoodAvailability. So, replace none with one of the three options listed above to change this.
Read an earlier post regarding DAGs Ref.
You can use the Shell to export messages from a queue on a computer that has the Microsoft Exchange Server 2010 Hub Transport server role or the Edge Transport server role installed to a specified file path. You can't use Queue Viewer to perform this task. However, you can use Queue Viewer to locate, identify, and suspend the messages before you perform this task.
Messages that get ‘stuck’ in a queue can be exported to a folder and you can later resubmit the messages once you fix the mail flow problem. To export a message (or all messages in a queue) you should first suspend the queue. Suspension does not prevent messages entering the queue, but it will stop them leaving. The following cmdlet suspends the queue.
[PS] Get-TransportServer | Get-Queue
This command will show you the queues on your transport servers (you may have more than one in your site).
You might have an example where your messages are failing to be sent because of name resolution:
You can see that the DeliveryType is set to DNSConnectorDelivery. The messages are queued for delivery to an external recipient by using an SMTP connector that's located on the local server and that's configured to use Domain Name System (DNS) for routing resolution.
To export the messages, first suspend the queue:
[PS] Suspend-Queue –Identity SRV1\20
Now that the queue is suspended you suspend the messages.
[PS]Get-Queue -Identity srv1\20 | Get-Message -ResultSize unlimited | Suspend-Message –Confirm:$False
-ResultSize unlimited is used as the default is set to 1000.
Now the messages are suspended you can export them. To see the list of messages in the queue type the following:
[PS] Get-Queue -Identity srv1\20 | Get-Message -ResultSize unlimited
The status should show the messages are suspended and you should see the Email subject heading and from address. Notice how the message ID is created and includes the Queue ID.
Now to export a single message:
[PS] Get-Message -Identity srv1\20\75 | AssembleMessage -Path c:\exportfolder\email1
To export all the messages from the queue is a bit more complicated. Try the following:
The above cmdlets will produce .eml files in c:\exportfolder\ with names like 1.eml, 2.eml. At a later stage you can ‘import’ the messages back into the submission queue by using the replay directory. The Replay directory receives messages from foreign gateway servers and can also be used to resubmit messages that administrators export from the queues of Exchange 2010 servers. Read this post for more.
Useful procedure for changing the product version of windows 2008 r2 standard to enterprise without reinstalling from media.
To determine the installed edition, run:DISM /online /Get-CurrentEdition
To check the possible target editions, run:DISM /online /Get-TargetEditions
Finally, to initiate an upgrade, run:DISM /online /Set-Edition:<edition ID> /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
For example, to upgrade to Enterprise from a downlevel version, run:DISM /online /Set-Edition:ServerEnterprise /ProductKey:YOUR SETUP KEY
(Thanks to Kimani and Jon)
RBAC can be used to allow administrators to perform a specific exchange task by being assigned a management role that has permissions to perform the task. Administrators can be assigned these roles directly, or multiple roles can be grouped together into management role groups. Management role groups are infact AD universal security groups. As you will see however, Exchange administrators should NOT be added to these groups using AD tools directly!
Each management role consists of management role entries. A management role entry is an EMS cmdlet or a script that users in a management role can execute.
For a list of management roles, type the following cmdlet:
[PS] Get-ManagementRole | Get-ManagentRoleEntry
The list you will see has quite a few roles!
If you take just one role for example, say ‘databases’ you will begin to see what's involved:
[PS] Get-ManagementRole –Identity Databases | Get-ManagementRoleEntry
So, users are assigned a management role (that can execute scripts that are defined by management role entries) by being assigned to a management role group. This can be very useful. For example we can create a management role group that only allows users to create exchange recipients. After we create the group and add users, management role(s) are then assigned to the group.
Several role groups exist in Exchange 2010 by default.
[PS] Get-RoleGroup
If we take a single role group for example ‘Help Desk’
[PS] Get-RoleGroup –Identity “Help Desk” | fl
The will list associated parameters for this group.
As you can see from the above screenshot, the roles assigned to the Help Desk management role group are shown. These are ‘User Options’ and ‘View Only’. You can also see under role assignments that it shows that these roles are assigned to help-desk! These default role groups can be found in AD in the Microsoft Exchange Security Groups
To add users to the role group of Help Desk use the following cmdlet:
[PS] Add-RoleGroupMember –Identity “Help Desk” -Member “Andrew Stevens”
This will add Andrew Stevens to the Help Desk role group. To determine the membership of the management role group try the following:
[PS] Get-RoleGroupMember -Identity "Help Desk"
This is great if the Help Desk group has the needed management roles assigned to it. From the screenshot above this includes management roles of “User Options” and View-only Recipients”.
User Options is a management role with the following management role entries, determined by typing the following:
[PS] Get-ManagementRole -Identity "User Options" | Get-ManagementRoleEntry
View-Only Recipients is a management role with the following management role entries, determined by typing the following:
[PS] Get-ManagementRole -Identity "View-only Recipients" | Get-ManagementRoleEntry
So you can see what Andrew Stevens can do having been placed in the Help Desk group.
You can also customize a role group to contain the roles that you need if you find the default roles assigned to a group do not fit correctly. If you find yourself changing the roles assigned to the default groups beyond recognition you might as well create a new group.
So, to add a role to an existing group try the following:
[PS] New-ManagementRoleAssignment -SecurityGroup "Help Desk" -Role "MailBox Import Export"
Now type the following again to determine the roles now ‘held’ by the Help Desk group:
[PS] Get-RoleGroup –Identity “Help Desk” | fl
You will notice that the RoleAssignments has changed to include Mailbox Import Export!
To remove the assignment type the following:
[PS] Remove-ManagementRoleAssignment -Identity "Mailbox Import Export-Help Desk"
If you need to you can create a role group from scratch. Lets create a role group called London Help Desk and assign roles to the group:
[PS] New-RoleGroup "Help Desk London" -Roles "User Options","View-Only Recipients"
Try the Get-RoleGroup cmdlet and you should see it listed.
So far the London help Desk team have the role of View-Only recipients and User Options. This is no different to the default Help Desk assignments. However you can add to it
[PS] New-ManagementRoleAssignment -SecurityGroup "Help Desk London" -Role "MailBox Import Export"
Legal Hold
An interesting role is Legal Hold. A legal hold in Exchange 2010 will keep e-mails even if the user tries to delete them. Note, the user will think the e-mail is deleted. The only way to actually see the e-mails is by doing a discovery search, and opening the discovery mailbox.
The legal hold role has the following assignments:
[PS] Get-RoleGroup | Where-Object {$_.roleassignments -match "Legal Hold"}
The output will show you that both Organization and Discovery Management groups have this role by default.
To grant our London Help Desk team Legal Hold type the following cmdlet:
[PS] New-ManagementRoleAssignment -SecurityGroup "Help Desk London" –Role “Legal Hold”
Type the following cmdlet for confirmation:
[PS] Get-RoleGroup | Where-Object {$_.roleassignments -match "Legal Hold"}
You should now see Help Desk London listed.
To turn this feature on we need to enable it for specific mailboxes. First you must have the role to do so. As mentioned, those in the Organization Management (and Discovery Management) have the Legal Hold role assigned. If you are doing this as a Domain Administrator then you are a member of Organization Management already.
[PS] Get-RoleGroup -Identity "Organization Management" | ft name,members
Now, determine which recipients you wish to define Legal Hold to and type the following:
[PS] Set-Mailbox –Identity “A User” –LitigationHoldEnabled $True
To check to see which mailbox has been enabled, type the following cmdlet:
[PS] Get-Mailbox | ft name,lit* –au
Performing a Discovery Search
You can still find and open the deleted emails using a discovery search. A discovery search can be made against any organisation mailbox (not just those on litigation hold). Here’s what happens:
Enabling Litigation Hold means that items never will be purged from the “Purges” subfolder, which of course results mailboxes growing considerably in size over time!
To perform a discovery search perform the following steps:
1. Perform a discovery search for the item you need to restore. This first involves navigating a browser to https://servername/ecp. This is on the CAS role (ecp is the exchange control panel). In Figure 1, the user ‘Al Pacino’ is in the LegalAdmins role group. This group has been assigned the roles ‘User Options and View-only Recipients’ (which is the same as the default Help Desk role). At this point Al cannot perform a discovery search and this is his ECP view (only Users & Groups).
2. Assign the Mailbox Search role to the LegalAdmins group using the following cmdlet: [PS] New-ManagementRoleAssignment -SecurityGroup LegalAdmins -Role "Mailbox Search"
3. The above screenshot shows us the ECP view after applying this step. You can now see that the ‘Reporting’ link is shown. Select this link.
4. After you select this link you should see a similar view as shown above. Remember that you can also add a user to the Discovery Management role group instead of creating a group and assigning roles to it.
Select 'New'.
5. As you can see there are a number of search methods. Select mailbox to search and select the user mailbox that has purged deleted items.
6. Provide a search name
7. Select 'Select a mailbox in which to store the search results' and choose the 'Discovery Search Mailbox' and click save.
8. After the search has completed (you may have to refresh) select the link that says open by the results output on the right hand side.
9. If you cant open the discovery search mailbox, you will need to grant the user access to it by typing in the following:
[PS] Add-MailboxPermission DiscoverySearchMailbox -User al -AccessRights FullAccess
NB. I changed the alias of the mailbox to this simpler name
10. You should now be able to open the discovery search mailbox. Once opened, navigate on the left to the search name and open the sent\deleted items folder. You should be able to find the item that was purged.
NB. If you wish you can create a new discovery search mailbox by using the following cmdlet:
[PS] New-Mailbox "HelpDeskDiscovery" -UserPrincipalName HelpDeskDiscovery@yourcompany.com –Discovery.
[PS] Add-MailboxPermission HelpDeskDiscovery -User al -AccessRights FullAccess
In the above example, our test user Al, can perform the discovery search and open the discovery search mailbox to find deleted items.
Having removed an Exchange Server (and arbitration mailboxes), reinstalling a second Exchange 2010 can be problematic. The deletion of the discovery mailbox will mean that the reinstallation of your Exchange 2010 server will fail. Run the following command:
[PS] New-Mailbox -Arbitration -Name FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042 -UserPrincipalName FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042@<Default_Accepted_Domain>
This should allow you to now rerun the installation program without failure.
To list the arbitration mailboxes type the following command:
[PS] Get-Mailbox –Database database name -Arbitration
This will list all the mailboxes that can be moved or removed.
To move them to another database, type the following command:
[PS] Get-Mailbox -Arbitration -Database db1 | New-MoveRequest -TargetDatabase db2
To remove the mailboxes, type the following command:
[PS] Get-Mailbox -Arbitration -Database db1 | Remove-Mailbox -Arbitration –RemoveLastArbitrationMailboxAllowed
Once you do this hopefully you should be able to uninstall Exchange using the Control panel
In a previous post I tried to detail some appropriate backup strategies. This post builds on these concepts and provides some practical details on what to do.
Perform Full Database Backups
A full database backup is a page-level copy of the entire database to backup media. You can execute a full database backup using any recovery model (i.e Simple, Bulk-Logged or Full).
To perform a full backup use the following:
USE master;
GO
BACKUP DATABASE CompulinxDB
TO DISK = ‘D:\Backups\compulinxFULL.bak’
WITH RETAINDAYS = 7, INIT;
RETAINDAYS does not actually delete anything, it is just marking the file to tell SQL Server not to overwrite this file before the retain time is up (in the above case 7 days).
INIT This option indicates that SQL Server will overwrite any existing backups on the target media with new backups. In other words, the backup that you are taking with this statement will be
the initial backup on the media.
It is considered good practice to ‘stripe’ the backup to two files on separate disks (and even controllers). So, the following syntax can be used
USE master;
GO
BACKUP DATABASE CompulinxDB
TO DISK = ‘D:\Backups\compulinxFULL.bak
DISK = ‘E:\Backups\compulinxFULL.bak
INIT;
GO
Differential Backup
The following can be used to make differential backups. Here the differential is appended to media containing the full backup:
USE master;
GO
BACKUP DATABASE CompulinxDB
TO DISK = ‘D:\Backups\compulinxFull.bak’
WITH DIFFERENTIAL,
RETAINDAYS = 7, NOINIT;
GO
Notice the use of the command NOINT. This option indicates that SQL Server will append this backup to any other backups on the target media. This option allows you to take multiple backups and target them to the same media set.
Perform Transaction Log Backups
Transaction log backups allow the DBA to manage the transaction log size while not requiring the overhead of taking frequent database backups. This is especially useful for large databases that are only moderately volatile. Before you will be able to take a valid Transaction log backup, you must do two things:
Try using the following T-SQL syntax:
USE master;
GO
BACKUP LOG CompulinxDB
TO DISK = ‘D:\Backups\compulinxTLOG.bak’
WITH INIT;
GO
Notice the use of LOG. If you wanted to take a subsequent backup of the transaction log and append it to the existing media, the statement would look like this:
USE master;
GO
BACKUP LOG CompulinxDB
TO DISK = ‘D:\Backups\compulinxTLOG.bak’
WITH NOINIT;
GO
At this point, if the database were damaged due to a corruption or loss of a data device, you would have to capture the orphaned log. You can do this with the following:
USE master;
GO
BACKUP LOG CompulinxDB
TO DISK = ‘D:\Backups\compulinxTLog.bak’
WITH NOINIT, NO_TRUNCATE, NORECOVERY;
GO
The above syntax has some new points to consider. NO_TRUNCATE will make a copy of the log but does not truncate the log. NORECOVERY allows you to capture a trailing log before making a restore. The database will be placed into a ‘restoring state’. Remember the database will not be accessible until a restore is made.
The database will look something like the following:
Partial Database Backups
In part one I mentioned backing up filegroups; ‘Breaking a large database into files or filegroups for backup allows you to back up portions of it on a rotating schedule when it might be too time-consuming to back up the entire database at once’. Perhaps only a small portion of the database is changing. If this is the case we can backup a filegroup (the group of data files that is dynamic) and therefore make a partial backup. You can also make the non-volatile data read only.
USE master;
GO
BACKUP DATABASE CompulinxDB READ_WRITE_FILEGROUPS
TO DISK = ‘E:\Backups\compulinxDB_Partial.bak’
WITH INIT;
GO
Notice the use of READ_WRITE_FILEGROUPS. This causes SQL to backup only the primary filegroup and any other read/write filegroups in the collection.
How to Restore
OK, now we know how to set the different recovery methods for SQL, the different backup methods that use these recovery types and actually how to implement a backup. However, a backup is only as good as knowing how to restore the database.
How to Perform a Full Database Restore
There may be several reasons why you need to perform a full database restore. These include the following:
To demonstrate this we need to do the following:
So, to take a full database backup,
USE master;
GO
BACKUP DATABASE AdventureWorks
TO DISK = 'E:\Backups\ADWORKSFULL.bak'
WITH RETAINDAYS = 7, INIT;
3. Using the the following T-SQL code determine the first name of an employee with the last name of Abel
USE AdventureWorks;
GO
SELECT FirstName
FROM person.Contact
WHERE LastName = 'Abel';
GO
The answer that should be returned is Catherine. I used to go out with a Catherine…
4. Let’s say Catherine wants to change her first name (perhaps to Irene, I won’t say it…). You can use the following to do this:
USE AdventureWorks;
GO
Update Person.Contact
SET FirstName = 'Irene'
Where LastName = 'Abel'
5. Now make a differential backup which will record the change of Catherine to Irene. You can do this using the following (this is also shown above). This should only take 0.684 seconds (or there a bouts!)
USE master;
GO
BACKUP DATABASE AdventureWorks
TO DISK = 'E:\Backups\ADWORKSFULL.bak'
WITH DIFFERENTIAL,
RETAINDAYS = 7, NOINIT;
GO
6. Now we need to restore the database using the full database so the first name is Catherine once more. To do this using the interface, simply right click your database and select restore:
7. Select Database and the following window will appear:
8. Using the backup history, you can select the correct backup or you can find it using the ellipses button on the right. Whatever you choose, select the full database checkbox only. Not the differential.
9. Click the Options page to see the restore options. As we are restoring over the top of an already existing database, select the Overwrite option. This prevents you from accidentally overwriting a database. The default is off. Click OK.
10. If you run the query to find the first name of the customer Abel, it should be Catherine.
A. Full Backup Restore (without differential)
You can do the restore without using the interface, by using the following T-SQL code.
USE master;
GO
RESTORE DATABASE AdventureWorks
FROM DISK = ‘E:\Backups\ADWORKSFULL.bak’
WITH FILE = 1,
REPLACE,
GO
Notice the use of FILE. The file value refers to a backup set file number. This option allows you to specify a specific backup in a media set based on its position number. This value was actually shown in the figure under point 7 above. You need this information to ensure that you are restoring the correct backup from the media if there are multiple backups stored on the same media. To determine the different backup set file numbers, try the following:
RESTORE Headeronly
FROM DISK= ‘E:\Backups\ADWORKSFULL.bak’
GO
Using REPLACE this restore will overwrite the existing AdventureWorks database on this server with the Full database backup. The first name of customer Abel is now Catherine.
B. Restore with Differential
Since we took a differential database backup after the customer name was updated to Irene we can restore the database using both the baseline full backup and the differential using the following:
USE master;
GO
RESTORE DATABASE AdventureWorks
FROM DISK = 'E:\Backups\ADWORKSFULL.bak'
WITH FILE = 1,
REPLACE,
NORECOVERY;
GO
This looks almost identical to our initial restore code except that we use NORECOVERY. This will put the database into a recovery state allowing us to then include the differential backup (allowing us to get the updated record that has changed customer Catherine to Irene). Just refresh the database in the interface and you will see. We can now include the differential backup while the AdventureWorks is in a recovery state. Remember you can ignore any previous differential backups since the ‘last’ differential is the only one you need. I have taken 2 differential backups following the full backups so the ‘position’ number equals 3. Its this file number that I’m interested in.
USE master;
GO
RESTORE DATABASE AdventureWorks
FROM DISK = ‘E:\Backups\ADWORKSFULL.bak’
WITH FILE = 3
GO
We do not use the REPLACE option as we are using the differential and not the full backup. Also notice that there is no indication that this is a differential. A query should show that the customer is Irene.
C. Restore with Full Backup, Differential and T-Log
To do this delete the backup file first and lets start from scratch. Once deleted, make sure our customer record is set back to Catherine. Then take another full backup.
USE AdventureWorks;
GO
Update Person.Contact
SET FirstName = 'Catherine'
Where LastName = 'Abel'
USE master;
GO
BACKUP DATABASE AdventureWorks
TO DISK = 'E:\Backups\ADWORKSFULL.bak'
WITH RETAINDAYS = 7, INIT;
Now that we have our initial backup once more, lets change the customer name to Irene, check and take a differential backup
USE AdventureWorks;
GO
Update Person.Contact
SET FirstName = 'Irene'
Where LastName = 'Abel'
USE AdventureWorks;
GO
SELECT FirstName
FROM person.Contact
WHERE LastName = 'Abel';
GO
USE master;
GO
BACKUP DATABASE AdventureWorks
TO DISK = 'E:\Backups\ADWORKSFULL.bak'
WITH DIFFERENTIAL,
RETAINDAYS = 7, NOINIT;
GO
Now you can check the File Position numbers, and you should see two files.
RESTORE Headeronly
FROM DISK= 'E:\Backups\ADWORKSFull.bak'
GO
OK, now we can change the customer name again (perhaps to Letitia…) and after take a T-Log backup.
USE AdventureWorks;
GO
Update Person.Contact
SET FirstName = 'Letitia'
Where LastName = 'Abel'
USE master;
GO
BACKUP LOG AdventureWorks
TO DISK = 'E:\Backups\ADWORKSTLOG.bak'
WITH INIT;
GO
Two .bak files now exist. Lets make a final change to our database. Change Letitia to Magda and check. Then we can backup the T-Log
USE AdventureWorks;USE AdventureWorks;
USE master;
Now if you check the file position numbers for the T-Log you should see two entries:
RESTORE HeaderonlyOK, so to recap the name changed from Catherine to Irene to Letitia to Magda. Say we want to restore the whole thing. Remove the database. Then restore the database using the full backup. AdventureWorks will be put into into restoring mode.
USE master;
GO
RESTORE DATABASE AdventureWorks
FROM DISK = 'E:\Backups\ADWORKSFULL.bak'
WITH FILE = 1,
REPLACE,
NORECOVERY;
GO
Now that's done, use the last differential. Check the file position numbers:
RESTORE Headeronly
FROM DISK= 'E:\Backups\ADWORKSFULL.bak'
GO
In my case position 2.
USE master;
GO
RESTORE DATABASE AdventureWorks
FROM DISK = 'E:\Backups\ADWORKSFULL.bak'
WITH FILE = 2
GO
Now, that's been sorted I apply the T-Log backup. Use position 1 then 2 in that order
USE master;USE master;
The final log is restored with the RECOVERY option to make the database accessible to users. In a real recovery scenario, this will usually be the orphaned log.
For some reason I have found the SQL recovery models and backup strategies a strange mix of being confusing but interesting. To help understand the subject of backup/restore and SQL’s different recovery models I thought I’d share my understanding with the world at large. Maybe if anyone out there is reading this you can contribute as well.
The backup strategy you use depends on a variety of recoverability considerations:
A backup strategy will require you to make decisions as to which kind of backup to make. And there are several. So you will need a fundamental understanding of these backup types.
Full Database Backup
A full database backup will truncate the transaction log and then copy every remaining data page and transaction log page to the backup media. The transaction log truncation will be non-reorganizing, meaning that no attempt is made to defrag/compact the log. It is simply truncated to the point of the last required transaction. Most backup strategies require a full database backup as the baseline for recovery. Remember that the log file will be truncated! From what I've read there is little point on having multiple log files. Keep just one. Also place the transaction log on a separate physical structure from the database. That way a loss of the disk containing the data files will not affect the log file. This may also help performance as log files are written to sequentially. Also, use RAID 1 so the log will be available in case of device loss. Regular backups will mean that not only will the log file not get too big but this will help prevent fragmentation.
Differential Backup
A differential backup will store all of the database pages that have been modified since the last full database backup. Note that this is a true differential backup and not an incremental backup. This means that each differential backup is inclusive of all transactions executed since the last full database backup and not simply since the last differential backup.
File or Filegroup Backup
If you are dealing with a very large database, you can back up individual files or filegroups. Breaking a large database into files or filegroups for backup allows you to back up portions of it on a rotating schedule when it might be too time-consuming to back up the entire database at once. If there is a failure affecting only one file or filegroup, only that portion and subsequent transaction logs would need to be restored. The log file is not in a filegroup.
Transaction Log Backup
This backup type will perform a non-reorganizing backup of the transaction log and store the transactions to the backup media. The backup types mentioned above store copies of the data pages at a particular time. This type of backup stores the actual transactions statements. When you restore using the full or differential backups, using the transaction log backup as well will involve replaying (if that’s the right word?) or re-executing the transactions on the log backup again which would be written back to the database. This process could take some time.
Recovery Models
Now that we understand (I hope) the different backup types, you need consider SQL’s three recovery models. Recovery is all about how the log file is treated by the SQL server on a day-to-day basis and what is made available for backup. Remember its all about the log file! Recovery in this context is about the level of logging and log retention.
You can determine the recovery model (which by default will be full) in the following way:
You can alter the recovery model using the following statement:
alter database TESTDB
set recovery Full
You should realize that the recovery model you choose will impact on the backup method you choose.
Simple
Simple means that the log file will be truncated each time the data pages and log pages held in RAM are flushed are written to disk (checkpointed). This keeps the log file small (there’s no point in backing up the log, in fact you can’t) which is good. But, you will not be able to recover to a point in time. You wouldn’t usually use this one. You might if it was a read-only database or you were developing a database application perhaps.
Bulk-Logged
The bulk-logged recovery model uses less disk space than a full logging solution by performing minimal transaction logging for the following operations:
A database that is in bulk-logged recovery mode cannot be recovered to a specific point in time if a bulk transaction has occurred. You still require log backups. A bulk insert (where you might be inserting a million rows into a table) would cause the log file to become very large if every transaction was recorded (if in Full mode) and would have performance implications. So you can switch to bulk logged from full just before the bulk operation. Once complete you set the recovery model back to full. The bulk operation would be logged as a kind of summary statement. So every transaction would be recorded while being in Full mode, then a summary of the bulk operation and then a continuation of all transactions when in Full mode again. What about the point-in-time recoveries? If the database is in the bulk-logged recovery model and no bulk actions have occurred since the last full backup, the database can be restored to a point in time. If, however, a bulk action has occurred, it can only be fully restored. So, it minimally logs bulk transactions but fully logs other transactions.
Full
The full recovery model is what you would use most of the time. It will give you the best recoverable opportunity at the expense of logging overhead however. Microsoft recommend that you use this model over the other two. The full recovery model will log every transaction to the log and is persistent after a checkpoint. A transaction is a change and any change on the database will cause an entry to be added to the log! A read does not cause a change so this of course will not cause an entry to be made to the log.
OK, so we are happy with the different backup types and with the different recovery models. The recovery models really describe how the transaction log is written to and whether the log truncates after a checkpoint or after a backup. With this combined knowledge we can consider the following backup strategies:
Strategy One: Simple
This strategy is suitable under the following conditions:
With this strategy transaction log growth is kept under control, you won’t have to backup the transaction logs but this will mean there may be a small amount of data loss.
How do you do it ?
Simple recovery means no transaction logs to use in the restore process. You won’t be able to return to a point-in-time and data loss will probably occur. But this of course depends on how dynamic the database is.
Strategy Two: The Database Only Backup Strategy
This strategy is suitable under the following conditions:
With this strategy, the transaction log is truncated because of a full database backup.
How do you do it?
As you can see, database only backup can be restored to a point-in-time where the that time starts from the last full backup to time of disaster. The orphaned log would have transactions from the last full backup to time of disaster. As long as the log stays safe on another disk from the database your OK. If you lose the log though you lose transactions from the last full backup to time of disaster. As long as you make regular full backups and you have low transaction volume you should be OK.
Strategy Three: The Transaction Log Backup Strategy
This strategy is suitable under the following conditions:
Instead of backing up the database file as a way of truncating the log, you backup the transaction log file. Backing up the transaction log will truncate log and keep its size under control. Although the backup up time will be relatively quick to do, the restore process will take time.
How do you do it?
So if your first full backup was taken on Monday at 1:00 AM and a disk failure occurred at 6:00 PM on Tuesday you would take the following steps:
Strategy Four: The Differential Backup Strategy
The transaction log strategy described above can be slow. The more you have the longer it will take to restore the database to the point of failure. If the changes made to a database are restricted to a particular number or subset of data pages, you could take differential backups instead of full backups. The transaction logs would then need to be restored only from the point of the latest differential backup.
Assuming the above model, a disaster at 1:00 Wednesday would require the following steps:
First step is to allow execution of scripts by changing the execution policy:
[PS] Set-ExecutionPolicy unrestricted (then say ‘Yes’)
Then copy and paste the following commands to install the pre-requisite operating system components needed
[PS] Add-WindowsFeature AS-NET-Framework,web-server,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Redirect,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Basic-Auth,Web-Windows-Auth,Web-Client-Auth,Web-Cert-Auth,Web-Filtering,Web-Stat-Compression,Web-Dyn-Compression,Web-Mgmt-Tools,Web-Mgmt-Compat,Web-Metabase,Web-WMI,Web-Lgcy-Scripting,Web-Lgcy-Mgmt-Console –restart
Pretty good article on how to fix PowerShell errors
This is how you convert wav files to gsm files used by Asterisk
for i in *.wav
do
sox $i -r 8000 -c 1 $(basename $i .wav).gsm resample -ql
done