How to Backup MySQL and FTP Scripting with PowerShell

Listen to this text

I’m a .NET developer, not a system admin. As such, I never properly learned how to write anything aside from “echo” this, “dir” that, and “ipconfig -toomuchinfo” to a command window. But now, since I manage my own server on Amazon AWS, I wanted a neat non-c# console-app way of backing up my MySQL Database and FTP-ing the resultant SQL file to another location. Because Amazon storage is expensive and my other hosting provider (HostGator) has almost unlimited storage space, I wanted to FTP things there, as a safe, inexpensive backup solution. This is the poor man’s disaster recovery, which like most poor-man solutions, works surprisingly well.

I challenged myself to do this whole task in just Powershell and windows commands on the task scheduler, and the solution I came up with seems to work really well. Here it is:

1. First, I backup my MySQL database. Create a backup directory, like: “c:\backup\”. Then, use the MySQL backup utility: this is a file called “mysqldump.exe”. If you installed MySQL on your computer/server, the exe is somewhere on your computer. Just find it and copy it into your shiny new backup folder. Open up Notepad or your favorite text-editor (like VIM if you still use that) and create a simple “.BAT” file that runs mysqldump on your database which spits out a SQL backup file in your backup folder. I name the file after the current date: so today’s file would be “backup.20161101.sql”. The backup script is really just one line of text that reads like the following:

mysqldump.exe --single-transaction -u[username] -p[password] [your_database_name] > "C:\backup\backup.%date:~10,4%%date:~7,2%%date:~4,2%.sql"

(Note: replace the contents in [brackets] with your actual situation. Don’t include the “[]” and don’t add any spaces. Notice, that username and password arguments strangely don’t have a space between the “-u” or “-p”).

2. Double-click the BAT file to make sure it works and creates a SQL file for you.

3. Next, prepare your Powershell file that will FTP your file away. Powershell files are plain-text files which end in a “.ps1” extension. Before you get started with Powershell, you need to change the execution policy of Powershell on the server. The execution policy is by default crippled for security reasons. To change this, open up Powershell command prompt as administrator and run this command:

PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

This will allow you to run your own Powershell commands but still requires downloaded scripts to have a signed certificate to execute. You will likely get a scary warning when you change this. (Please read up more on execution policies before doing this.)

4. Finally, create your Powershell script that will FTP your SQL files to your FTP server. Because the file name scheme I have is predictable, I know what the name of the file is that I want uploaded each day. Here is the script I created; just copy this to a text file and replace the [brackets] with your situation and save the file. I called the file “FtpDataFile.ps1”:

#we specify the directory of the file we want to upload
$Dir="D:/backup/"

#ftp server
$ftp = "ftp://[ftpUrl]"
$user = "[FTPusername]"
$pass = "[FTPPassword]"

$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
$item = "backup.$(Get-Date -Format 'yyyyddMM').sql"

"Uploading $($Dir + $item) ..."
$uri = New-Object System.Uri($ftp+$item)

$webclient.UploadFile($uri, $Dir + $item)

5. Set up another task that runs your Powershell file on the server (space it out at least 15 minutes after the MySQL backup task). In order to run Powershell on the command window, you need to essentially execute the “Powershell.exe” process and pass the script file as an argument. So it would look like this:

c:\> PowerShell -File .\FtpDataFile.ps1

(Note: The “.\” is a relative directory symbol meaning, “directory above this one”; you may need to adjust your path.)

You can easily consolidate all this to just one Powershell script. And if you do, be sure to put in a wait/sleep command in there between the two tasks to make sure the SQL file is finished building before FTP-ing it away.

Baby Shh Sounds

Listen to this text

What is it about the sound, “Shh”, or “Shhh” or “Ssh” that causes babies to calm down and if you’re lucky, sleep. I’m not sure why it’s so effective. I hear it may be related to it’s similarity to the sounds made in the womb: of the muffled rushing of liquids in the body that a baby associates with comfort and safety. It seems to work on crowds too. We were all once a baby — so they say. Maybe we never quite shuffled off that instinctive feeling of quiet and calm when we hear that sound. And so we relent, trance-like when our neighbor shushes us during Zoolander 2.

For our daughter, in the middle of the night — say 3AM — if she is still wide awake after a feeding and I’m trying to get her to sleep, I will play a recording of this sound over and over again. I will raise the volume and slide the phone under her cradle. This works most of the time. If you’re in a similar situation with a midnight-jazzed baby, you can download an hour-long MP3 of the shh recording that I use below and let it play in the crib. Load it on your phone or tablet and hopefully it works well for you and your little one.

Shushing Baby MP3 (86 MB; 59 minutes) play | download

Stalled Black Truck

Listen to this text

There is no better time to write on your blog, I always say, then when you should be writing something else. I have friends who run a fishing blog. The should in this particular instance is a short paper I need to write for my Postcolonial Medieval literature class. I’m stalled on the first sentence of this paper, and not going anywhere fast. Ironically, I tried to start my old F-150 today for the first time in 5 months, in hopes to use it to help a friend move this weekend, and of course, it doesn’t start at all. In fact, it makes absolutely no sound whatsoever when you turn the ignition key. Attempts at jump-starting it with my Passat proved fruitless. It will have to be towed to my mechanic (who is of course named “Joe”) in the morning to try and resuscitate it back to life. Trucks are not easy to push — I learned this today. Who knew: you can really feel that extra 1,000-lbs of material.

The dead, black truck sitting in front of my house that can’t be moved, is a fitting metaphor for this paper that is going no-where (if you’ll allow me to return to it). I’ve since proceeded to Edgar Allen Poe’s choice remedy to lubricate the fused, stalled, an unresponsive neurons/dendrite connections in my brain. I must admit, it is helping — I think. Or, at least it’s making “other” writing easier.

Well, it was … I suddenly have nothing further to say.

The CFP List: www.cfplist.com

Listen to this text

As a professional in literature, you are constantly on the prowl to present at conferences. So, as you can imagine, grad students are strongly encouraged to attend and submit papers to conferences whenever possible. “Real” conferences, to me, are super intimidating still. I can’t help but have nightmares that someone is going to ask me a question that I can’t answer. Or worse, a question to which I can’t even figure out the question.

Lately I’ve been scouring the web for friendly graduate student conferences which I think I may be able to handle. Unfortunately, there are very few sites that have a nice rich repository of CFPs (Call for Papers). Sorry, “CFPs”, the acronym I had to learn lately, is basically a beacon call for academics to submit a proposal to present. So a fellow English Grad student and I created our own CFP database called cfplist.com. The goal is to warehouse all CFPs floating out there. Well, we’ll see if it takes off!

Make sure to check it out: http://www.cfplist.com

IIS7 and non-www prefix on domain

Listen to this text

Be warned, this is a somewhat technical post. It took me a while today to figure why my webserver running IIS7 was not loading up my website whenever the “www” prefix was not included. So for instance, “ariyam.com” was sending out a 404 error, while “www.ariyam.com” was working correctly. After spending a lot of time Googling my way to a solution I actually ended up in a dead-end and had to figure this out on my own. Others had suggested adding “redirect” rules, but that didn’t seem to work for me. Turns out the problem is incredibly easy to fix on IIS7. Here’s how you do it:


  1. Firstly, open up a command prompt and make sure “www.domain.com” and “domain.com” are pointing to the same IP. You can either run “ping www.domain.com” or use “nslookup www.domain.com” to do this. If the IPs don’t match, you have a DNS issue which you need to resolve first (don’t ask me how).
  2. Assuming the IPs match for the non-www domain and the regular domain, you can then proceed to your web server and launch the IIS7 management (inetmgr).
  3. The issue is something called “binding”. All you have to do as add another “binding” entry on IIS for your website. It takes about 10 seconds. Once you have IIS7 open, click on your website and click the Binding link on the right, click add, then put in the domain name minus the “www” prefix. See the screen shots below.
  4. And that’s it!


(Un)Comfortable Reading Positions or “Norton Neck-Cramps”

Listen to this text

There’s a common problem plaguing english grad students — in fact, it may have spread to all students generally. It is a problem oft dismissed as irrelevant; never talked about; never addressed, and students suffer alone when confronting it. I of course refer to this:

The 3,000 page neck-aching Norton Anthologies: textbooks that work your mind as well as your forearms. Pictured here is my Norton Anthology of Theory and Criticism. Just look at it! It laughs at your futile attempts to read it comfortably. The first 500 pages or so are by far the worst of the experience — the book constantly shutting from the stress on its binding. Sometimes I look forward to mid-semester only because the book balances better on a table. Word of caution: do not attempt to read this book in bed, unless you have two spotters (very few people do). If you read it in a chair with your lap (which sounds reasonable) you will find your eyes cannot make out the micro-print typeface. The book must be 10-12 inches from the eyes, and the only way to accomplish this is on a flat table, with your neck precariously hinged, taking frequent breaks to relieve the stressors on said neck.



Fortunately, that has all changed. I’ve finally discovered a more comfortable way to read this book! I never thought I’d see this day, but alas: Behold, the book holder!

This ingenious device props books upright allowing it to be read easily at eye-level, relieving neck stress, minimizing head movements, and overall providing a more comfortable and healthy reading posture for uber-large textbooks.

In my mind, this is a revolutionary find (though, apparently a hushed secret among law students who have known about it for years: damn lawyers and their secret clubs!). I bought mine from Amazon for about 8$ and love it. It has already dramatically improved my reading experience, and as result, no doubt will seep into better grades. Simply search for “book holder” on Amazon and always remember who showed you the way 😉

[wp_ad_camp_2]

Statement of Purpose Writing Tips

Listen to this text

Statement of Purpose essays are incredibly difficult to write. This past April, I began the application process anew for my PhD. Of course among the items required was a statement of purpose. Worse, I read it’s often considered the most important component of the application. The doctoral degree emphasizes specialization, focus and (gulp) “purpose.” Add to that, if you’re applying to a program where “writing” is central to success (English for instance) a Statement of Purpose holds evermore weight.

But after tips from friends, professors, and after studying several samples, I discovered advice to help craft a decent Statement of Purpose.

The following are 10 tips for anyone needing to write a Statement of Purpose for graduate school.

  1. Be humble. Don’t be a know-it-all who writes-out advice in lists of ten simple and fairly obvious statements.
  2. Leave the lofty goals and ambitions to Miss America pageants: Be real and be yourself. The world will not be a better place if you’re accepted to graduate school. True, you are special and unique; however, there are billions of people who are also special and unique. So, act accordingly after weighing in that proportion. A “real” person is much more refreshing and interesting then someone effusively optimistic/naive.
  3. Your opening sentence and/or opening paragraph are the most important parts. Spend time with them. Don’t make them generic and don’t take over-the-top risks to stand out; like opening with a haiku or some unnecessarily provocative statement.
  4. Stand out with specificity.
  5. Avoid all and every sort of cliche.
  6. Demonstrate focus and drive indirectly through illustration. Don’t explicitly say something about yourself that cannot be corroborated.
  7. Keep a common thread running through the essay.
  8. While you may not know exactly what you want to focus on in graduate school, it helps to highlight a focus area. There must be at least one thing you’re interested in. Find out what that is and talk about it. Allow your own natural interest to color your enthusiasm (don’t feign excitement when it’s not there).
  9. Have different people read your essay to offer their feedback. Think about using custom assignment help.
  10. Re-read the first paragraph of your essay and honestly ask yourself “If I were a random stranger, would I want to read on?” If not, don’t feel afraid to scrap that entire paragraph. It’s not about length, it’s about quality of content. Sentences should be painfully crafted, revisited, rewritten — polished to death as it were. If your statement of purpose doesn’t take you over a week to write, or if it doesn’t look drastically different than the first rough draft, it’s probably not ready for submission.

Explore yourself through the essay. You may come to discover that you have a clearer idea of yourself and your own purpose for pursuing graduate work by the very act of writing about it. In some respect, it can be an exercise for yourself.

Okay now, here’s a test: look at the paragraph you just read right before this. If any part of your essay reads like that, delete it! While it contains a modicum of truth, it’s wrapped in corny, lofty, non-specific, language that reads a bit like pablum — which has no place in your essay!

A Sample Statement of Purpose Essay

Melodie Professional Edition

Melodie ProOnce upon a time, churches used overhead projectors to display song lyrics on screen for people to follow. This was not bad for its time, but it did require a lot of work on the operator. It was tedious (and stressful) to search for songs fast under pressure; one needed nimble fingers to jump to different stanzas quickly, and strange cardboard-contraptions to obscure certain lines. And apart from rolling back the projector and re-focusing, adjusting the size and resolution or the background was difficult if not impossible. But thankfully, in this era such contraptions are a thing of the past.

After many long months of programming, I’m happy to introduce our latest software creation: Melodie. With Melodie, you can store your entire library of songs on a computer, and then quickly retrieve them, and have lyrics scroll down at a certain pace, and/or quickly queue up the next song or stanza at the direction of a song leader. The idea is distraction-free worship.

But if you need to add a little color or make a more dynamic song/bible presentation (for a youth choir, or Sunday School graduation for example) you can still do that with Melodie!

With the new Professional Edition of Melodie you can set dynamic backgrounds (picture clouds moving) via videos. The text, fonts, margins etc. are all customizable. In fact, Melodie Professional has a whole suite of neat features, such as:

  • Dual-Screen Output
  • Direct X-based text scrolling for enhanced smoothness and control
  • Jump quickly to individual song lines as well as stanzas
  • Supports wide screen output aspect ratios
  • Easy to use (cliché-sounding, but it really is easy)
  • Bulk import your song data from a spreadsheet
  • Songs can be “tagged” by keywords to aid in searching.
  • Video loop and gradient background options
  • Advanced full-text song searching algorithm
  • Quick Bible passage look-ups (comes with the KJV and ASV bible)
  • Shortcut / Function keys make operation a cinch
  • Melodie keeps itself up-to-date automatically

Check out The Melodie Professional Edition website to download and learn more!

Mission Window Seat

It’s getting colder out, so I’ve hustled to finish my final woodworking project for the year. I put the last coat of poly last night. It’s called: The Mission Window Seat. It’s made entirely of Red Oak (my first time working with oak).

Twenty Months Later

Listen to this text

Twenty months. Imagine that. It’s been that long since I wrote anything on this site. It’s amazing to think I started this blog a little over 6 years ago, and almost two of those years was left without writing a single thing (at least on here). I’ve since upgraded my wordpress version to the latest one — the update to end all updates apparently. The new versions can automatically upgrade themselves without the need to FTP anything across, backup a database, and/or delete files manually. (At least that’s what I think I read.)

In the last two years, I’ve since discovered woodworking and how awesome it is especially if you have these Ariat Work Boots review 2016
. Most of my evenings are spent in the garage (which is now a balmy 1.6 C or 29 F) and is my new safe-haven. I can spend hours on hours in there getting lost in my work, forgetting to eat, and only stopping when I’m physically and mentally so tired I end up making costly mistakes. So far, none of those costly mistakes have resulted in amputation — thank God!