Browsed by
Month: December 2016

Backup your Linux system via Powershell. WHAT?!

Backup your Linux system via Powershell. WHAT?!

I have a Linux. I have a Powershell….ahhh…

Sorry. Ahem.

Anyway. Yesterday I found out that Powershell can invoke SSH commands to Linux machines. And that’s bonkers, you can control your Linux system and leverage PS functionality together. Let’s see how you deal with it.

Adding SSH capabilities to Powershell

Microsoft once promised us to add OpenSSH to Powershell, we still didn’t get it. But whatever, we have an alternative called Posh-SSH. All you need is love the command:

After that connect to your Linux machine by creating a new SSH session:

 

2016-12-09-11_44_46-ssalab-amust-local_7232-remote-desktop-connection

 

Invoking SSH commands

Now as a proof of concept let’s try something simple.

2016-12-09-11_35_58-ssalab-amust-local_7232-remote-desktop-connection

Holy cow! It returned the hostname!

Using Veeam Agent for Linux

But I wouldn’t be a backup guy if I didn’t try to backup something with all this. So let’s try using some of the commands of Veeam Agent for Linux.

2016-12-09-11_56_02-ssalab-amust-local_7232-remote-desktop-connection

As you see, the output of shell is truncated, so if you care for the output, apply a little cheat and try again:

2016-12-09-11_59_36-ssalab-amust-local_7232-remote-desktop-connection

Now that is better, but the string is not readable, so let’s apply some formatting! (it soounds like it something obvious, but I killed a lot of time trying to make it look right, and the rules are weird)

2016-12-09-12_04_15-ssalab-amust-local_7232-remote-desktop-connection

Now that looks about right. Not perfect, but definitely readable.

Hey I just backed it up!

What’s next?

Well, I just discovered this stuff, so there’s a lot to do. You can combine Linux commands and powershell to create some powerfull scripts. I’m no scripting guy by any means, but even for me  that sounds pretty exciting.

As for you guys, I hope that opens some automation opportunities for you, just turn on your imagination.