Archive

Archive for September, 2023

Transfer #IIS bindings from one server to another using #Powershell

Ok, it’s a common task, you’re migrating from one server to another, but you have one website that responds to 100’s of bindings, and you have to move them. Of course you can copy and paste one by one, but here’s a script to do so. It also works with IDN domains.

First, on the source server, run this;

Import-Module WebAdministration

$siteName = "YOUR_SITE.COM"
$exportPath = "C:\TEMP\bindings.csv"

$bindings = Get-WebBinding -Name $siteName | 
            Where-Object { $_.protocol -eq 'http' } | 
            Select-Object protocol, bindingInformation

$bindings | Export-Csv -Path $exportPath -NoTypeInformation -Encoding UTF8

Then, copy the file bindings.csv to the new server, and import them using this

Import-Module WebAdministration

$siteName = "YOUR_SITE.com"
$importPath = "C:\temp\bindings.csv"

$bindings = Import-Csv -Path $importPath -Encoding UTF8

foreach ($binding in $bindings) {
    $protocol = $binding.protocol
    $bindingInformation = $binding.bindingInformation -split ':'
    $ipAddress = $bindingInformation[0]
    $port = $bindingInformation[1]
    $hostHeader = $bindingInformation[2]

    New-WebBinding -Name $siteName -Protocol $protocol -IPAddress $ipAddress -Port $port -HostHeader $hostHeader
}

This doesn’t work for HTTPS domains, since you need to copy the public/private keys as well, and it’s more complex.

Categories: Uncategorized

Optimizing #MySQL performance on Windows

The MySQL community edition, when installed using default settings is limited to 128MB of memory, which makes it unobtrusive, and won’t hog resources if misused, which is fine. But sometimes you need a blast of performance, to help run queries fast, even if it gets greedy with memory.

Everybody knows that memory is faster than disk, so if you find that MySQL is using 100% (or maxing out), disk usage, and only using 128MB of memory, then you will benefit from giving MySQL more access to available memory. Lets say your desktop machine is 16GB, you can easily give it 10GB (10G) of memory without affecting system stability. Ypu can see all of this in task manager.

So, assuming you’re using Windows, you need to open notepad (or another text editor) as Adminsistrator and then open the file C:\ProgramData\MySQL\MySQL Server 8.0\my.ini

Find the part that says

innodb_buffer_pool_size=….

and change it to

innodb_buffer_pool_size=10G

Then stop and start the MySQL service (Using Services.msc).

As you start running heavy queries, you should see the memory usage of MySQLd go up, and the disk usage go down.

Categories: Uncategorized

gnutls_handshake() failed: Handshake failed – #GIT #error #Ubuntu #BitBucket

When trying to connect via GIT to BitBucket from an older server, I got this error;
fatal: unable to access xxx : gnutls_handshake() failed: Handshake failed

After updating GIT, CA root certifiates, rebooting the server, nothing seemed to work.

Then I did;

Get the SSH public key as follows;

cat /home/ubuntu/.ssh/id_rsa.pub

Then log into bitbucket, and press the settings cog in the top right, then “Personal Bitbucket settings”, then SSH Keys, 

then paste in the public key from the result above. 

Once added, you can do;

git clone git@bitbucket.org:XXX/XXX

Hope this helps someone!

Categories: Uncategorized