Sunday, 29 December 2019

Useful script for moving files

Periodically I get a large number of files arrive from various servers that have a similar naming convention. I need to manage these files quickly to push them into various folders. Here is an example of the naming convention:


So there are two elements to these files - the server ID (XX) and the number of the file - from 0000 to 9999. I want to search for files from Server01 and copy all of them to a directory. How do I do this quickly? With the magic of bash command line scripting!

So here is what the single line script looks like:

for i in `find . -name Server01.File*.bak` ; do cp $i /path/to/storage/Server01/ ; done

To break this down a bit:

for i in `find . -name Server01.File*.bak` assigns all files that match the name Server01.File*.bak to the variable i.

The * serves as a wildcard, so it matches all the files from 0000 to 9999.

The next bit:

do cp $i /path/to/storage/Server01/ copies all the files that are assigned to the $i variable to the location I want them to go.

And the ; done finishes the script. Neat huh? The "name" bit could be anything.


Tuesday, 4 June 2019

Getting into it with Microsoft Azure Cloud Computing

For work I've been playing with Azure a bit - and if you're not aware of what Azure is I'll explain. It is Microsoft's cloud computing offering similar in many ways to Amazon EC. I quite like it - especially because they give little not-for-profits like us $3500 USD of sponsorship to run stuff. It has allowed us to make a few tentative steps into the cloud space and expand our operating horizons.

As a beginner with Azure I wanted to just run up a basic machine and it allowed me to do that pretty easily. The wizards are straightforward and it's a matter of understanding the different terminologies to get to what you want from the system. The basic components of an Azure box are:
  • the VM itself
  • network interface card
  • disk
  • network security group
  • Public IP address. It looks a bit like this:

The Virtual Machine is set up along a series of different options - you can guess most of them. Number of CPUs, RAM and the system disk plus any data disks. There are plenty of present options and it's pretty neat that you can jump around with them. I initially had a couple of our VM's set a bit high and dropped them down. It required a restart and that was it.

With any virtual machine - particularly in the cloud - it's absolutely CRITICAL to understand how much it will cost per month to run the thing. The CPU/RAM and Disk all have different costs, as do backup solutions and other bits you can add. Most of them only cost you money when the machine is running though. For us, we're looking at running some pretty sizeable Windows Servers but only during business hours (8am to 6pm) Monday to Friday. So 210 hours a month instead of 600+. It is a much cheaper way to do business and worth checking out if your budget is tight.

Back to Azure. Once the machine is up and running, then the management is done by SSH or RDS or whatever you'd normally work from. Console access is available, which for us was really important - I was using SSH Keys for authentication but the Azure side kept changing which was fucking frustrating. Had to keep deleting the old key and then fixing it, and then the auth key wouldn't work. I eventually gave up and went back to good old fashioned usernames/passwords.

Although this isn't ideal, the firewall setup is straight forward and comprehensive. My VMs are not accessible from any network apart from our own (which has made home support a non-event). It protects our assets that little bit more and so it's a good time investment to work on. Here's a tip - if you're using Let's Encrypt to provide you with SSL Certs, then you will periodically need to open Port 80 to the world for that to run the tests against. I say that, knowing full well that on one server it's 100% the case and on another it's not. WTF? I dunno it's weird but anyway, this is the world we live in. I'd show you more of the interface, however there is a too much proprietary stuff there. You can sign up for a free Azure trial though which is pretty great. I recommend doing that to see what you can find. There are free offerings available too which are very useful for evaluating their products.

I have been impressed by Azure over the last 8 months of using it. I find the interfaces to be straightforward and the integration with Office365 to be pretty neat too. Give it a try and see how it compares for you against Amazon or Google Cloud (which is a very different beast indeed).

Thursday, 3 January 2019

Windows 10 Enterprise Eval - gotchas

After an annoying turn of events where my Windows 10 Enterprise USB drive failed, attempts to install Win10 onto a computer failed miserably. I turned to the net and managed to get my hands on Microsoft's Windows 10 Enterprise Evaluation. I have an enterprise key so I thought - cool! Here's the opportunity to get it going and to then upgrade the license later. Full install, patched etc and all is swell. Except when I try to upgrade.

I straight up tried changing the licence key only to get a variety of errors, most of which are pertaining to the activation system being unavailable. The I try this: but it doesn't work either.

Next I'll try this:

And if all else fails, in goes the bootable USB I've now created. If only I'd had this in the first instance I would not be writing this note to myself (and to you).

If only I'd found this: first! I might have been able to dodge much of the problem in the initial stages. Learn from my pain :-)