Backup Linux using PowerShell

As a follow up to Backups are Important! Here is How I do it! I decided I should let everyone know how I am handling remote backups on my blog. It’s not hard to see that I am obviously a Windows guy, I am also glad to admit that I personally prefer Linux Servers for my blog, it’s a smaller impact, and much much cheaper; although I have considered Azure more than once.


So as I have listed on my last blog post I was bit in the rear on backups and decided to go for overkill. I already have a ton of storage at home so I figured there had to be a way for me to utilize that storage and have a remote backup that isn’t in my Dropbox and isn’t a manual process. So I began researching ways to interface with SFTP, I found out that WinSCP has .NET Assemblys available, and I’ll admit I am far from a programmer and didn’t want to try to hook into that using PowerShell. So I let it sit for a couple of weeks and by god an example of exactly what I wanted to do was posted, and all I had to do was minor tweaks.

I found Session.SynchronizeDirectories method and Session.FileTransferred event example on the WinSCP site and thought by god this will do an rsync using PowerShell! So I downloaded it reviewed the code, added my login information and changed line 72 from


along with the directories I was synchronizing. Once that was completed all I had to do was setup a scheduled task to execute after my local backups were completed. Now some of you may think that this is extremely unsafe because it has my logins as plain text that is true, however the account I am using only has read access to these servers and I personally would be a lot more concerned about my local machine having been breached than someone having potentially found a read only login to my servers.

I decided to make modifications to the script for end users not to have to scroll looking for variables to edit, so please feel free to use my very lightly tweaked version.

Currently between my two servers I have over 33 GB of backups on a 5.46 TB Raid 5, eventually I will need to add a scheduled task that removes old backups however that day is far away from now.

NOTE: There is a weird issue that my friend John Gullion helped me discover using this .NET Assembly that requires you use the x86 PowerShell, so when executing it be certain that you have it running under x86.

Be Sociable, Share!

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">