Migrating websites between Virtual Private Servers

So I recently found myself needing to move websites from one VPS to another.   In this case it was the same provider but different datacenters within the US.  While I was contemplating options I discovered a few rather simple tricks and thought I would share them here.  My research didn’t turn up any complete post on migrations (though a few came close) and I wanted a somewhat comprehensive guide.  As always this advice is given AS-IS and I cannot be held responsible if you destroy your data, bork your servers, or get your account suspended by your host.

Anyway let’s get started.  This post assumes you are moving between similar platforms and architectures.  I’m going from CentOS 6 to CentOS 6 both are x64 platforms.  If you are trying to migrate between dissimilar platforms (Debian to CentOS) or architectures (x86 to x64) there is a good chance these instructions will not work.  I’m also assuming you have installed all the correct packages on your new server.  You can do a “yum list installed” in your source server to see what all you have installed.

The first step is an initial sync of your files.  Depending on the size of your web root and the server’s Internet connections this might take a while.  I suggest you start this before bed then check it in the morning.  There is no need to worry if it fails as we will be running this  multiple times.  We are going to use rsync for the entire file sync process.  The command you need to run is:

rsync -avzhe ‘ssh -p 22222’ root@OLD.HOST:/var/www/ /var/www/

This command needs run from the DESTINATION SERVER.  If you are looking into the specifics of the rsync command please see here.  The only thing I will note is the number after the -p is the SSH port number.  22 is the default.

We can run this command as many times as needed as it will only bring across changed files or those that didn’t exist the first time.  If the initial sync fails simply run it again.  Now we need to move over any config files, this is easiest to do with rsync as well – again run from the destination server:

mv /etc/httpd /etc/httpd.old
rsync -avzhe ‘ssh -p 22222’ root@OLD.HOST:/etc/httpd/ /etc/httpd/

The first command moves the existing httpd directory to a backup location while the second brings over all the configs from the old server.  There are a handful of directories you will want to run this on including, but no limited to:
/etc/httpd/
/etc/postfix/
/etc/php.d/
/etc/mail/

Once you have done this it’s time to pick the migration time and run a few more commands.  I choose early on a Sunday for this final migration.  Shut down the Apache service on the source server.  Time to migrate the MySQL databases.  This command works nicely but need run from the SOURCE SERVER:

mysqldump -u root -pPASSWORD –all-databases | ssh -p 2222 root@NEW.HOST ‘cat – | mysql -u root -pPASSWORD’

Of the PASSWORD variables listed there the first is the MySQL root password of the source machine, the second is the MySQL root password of the destination machine.  You will be prompted for the main root password of the destination machine when you execute this command.   The number after the -p, as before, is the SSH port number.   As with the rsync this command may take a while.  Now time to run the final sync on the web root.  Same command as before:

rsync -avzhe ‘ssh -p 22222’ root@OLD.HOST:/var/www/ /var/www/

Assuming not much time has passed between the first time you ran this and now it should run fairly fast. 

Moment of truth, shut down all web service on the SOURCE server: MySQL, httpd, postfix, etc.  Start all services on the DESTINATION server.  Then change over your DNS to point to the new server.  Assuming everything came up as expected you should be golden!

Test all the sites you had running on the old server paying close attention to things like SSL and 301 redirects handled by the .htaccess files. 

You have now migrated to a new server!  While this seems like a lot of steps when you actually dig down into it there really isn’t much here.  Feel free to leave a comment with your experiences or any questions/comments you may have. 

Raspberry Pints install on other operating systems

There was some interest in a guide to install Raspberry Pints on various other operating systems to I will attempt to provide some guidance here.  If there are any questions please don’t hesitate to ask.

Standard disclaimer here.  I’m not liable if your machine bursts  into flames, your girlfriend leaves you, etc.  Everything here is provided AS IS without any warranty expressed or implied.  Use these instructions at your own risk!

Now that we have that out-of-the-way, let’s begin!  Your first step is to install XAMPP.   I won’t provide instructions here as there is plenty of information on their website.  However if you run into trouble please let me know.

After install you should have a working webserver and MySQL server on your machine.  You can try to access localhost in your web browser to confirm.  If everything is working correctly you need to set a MySQL root password.  You can set a password at this address http://localhost/security/

Next step is to obtain a copy of Raspberry Pints here.   Unzip this and move it to your XAMPP www root.  I opted for a subdirectory of “rp” just because I have multiple websites on my machine.  Make sure that whatever you choose the index.php file is in the root of this subdirectory.

Now you need to run the installer.  Assuming you choose the “rp” directory as above the installer will be accessible here: http://localhost/rp/install but you can adjust as needed.  Follow through the steps using the official instructions for reference.  The password will be the one you set above on the security page.

All done!  To full-screen the display hit F11.  You will have to use the arrow keys to navigate as it appears this isn’t setup for a mouse.  Hopefully this is helpful to someone.  If you encounter any issues please don’t hesitate to let me know so I can assist and adjust this guide as needed. 

Nearly 4 years…and all it takes is a random post on an internet forum

Rainbow Bridge
Just this side of heaven is a place called Rainbow Bridge.
When an animal dies that has been especially close to someone here, that pet goes to Rainbow Bridge. There are meadows and hills for all of our special friends so they can run and play together. There is plenty of food, water and sunshine, and our friends are warm and comfortable.
All the animals who had been ill and old are restored to health and vigor; those who were hurt or maimed are made whole and strong again, just as we remember them in our dreams of days and times gone by. The animals are happy and content, except for one small thing; they each miss someone very special to them, who had to be left behind.
They all run and play together, but the day comes when one suddenly stops and looks into the distance. His bright eyes are intent; His eager body quivers. Suddenly he begins to run from the group, flying over the green grass, his legs carrying him faster and faster.
You have been spotted, and when you and your special friend finally meet, you cling together in joyous reunion, never to be parted again. The happy kisses rain upon your face; your hands again caress the beloved head, and you look once more into the trusting eyes of your pet, so long gone from your life but never absent from your heart.
Then you cross Rainbow Bridge together….
Author unknown…

I miss your Otter.

http://www.reddit.com/r/cats/comments/1cr4re/i_lost_my_best_friend_today_his_name_was_gregory/c9jbm0k

Fuck You Chipotle!

Adventurrito, I mean seriously…did you not expect the load on your servers for this 20th anniversary challenge?  For a $445 MAX year prize this is pretty fucking worthless if I have to spend all evening trying to reach the site and send my answer.    Especially if this will continue for the duration of the challenge.  Y’all are going to spend so fucking little in prizes (and obviously the infrastructure isn’t anything to write home about) that this is actually beyond worthless.  Get your shit together or GTFO.

Arduino Temperature/Power Loss Monitoring – Part 1

Since I was unable to find a complete post on this I decided to write one.  I found a lot of good information from other blogs and websites but nothing exactly what I wanted to do.  I’m going to put together what I hope will be a complete guide for home temperature monitoring, power loss, and reporting/graphing (though that last piece will come in a later post).  You are welcome to use any part of this or use it all.  All code is open source under WTFPL.

Basically what I wanted was the ability to monitor the temperature at multiple points in my house.  I also wanted to monitor the power and alert on a power outage.  Since the Arduino board is plugged into a UPS it will stay running for a while after the power goes out.  Obviously without a UPS your Arduino would be unable to alert on a power outage.

First things first, here is a parts list that I used to make this happen:
– 1 Arduino Uno R3
– 1 Arduino Ethernet Shield R3
– 1 4.7k Ohm resistor
– As many DS18B20 temperature sensors as you want.  I will use 4 for this project.
– An LM35 analog sensor from here (optional)
– Wire – I am using spools of 2-pair telco wiring that I’ve had in my basement forever.
– Breadboard for connecting sensors and power to the Arduino board.
– ~9V Power adapter for Arduino board (only if you don’t have USB power nearby)
– 5V SWITCH MODE power adapter for power loss monitoring (optional)
– LAMP web server stack.  If you want to run this on Windows I suggest XAMPP.

(Depending on where you go for this and what you already have you should be able to get away for about $100 US)

Additionally here are the skills you need:
– Basic soldering
– Basic web programming/LAMP skills
– Wire pulling
– Time

Final notes before I get started with the actually how-to.  I will do my best to give enough details on everything (without going overboard) for you to make this work.  If you get stuck though please feel free to leave a comment or message me.  I also give no guarantees on the code.  If it works for you, wonderful.  If it sets your computer on fire, I’m not responsible.  Oh and if your system gets hacked from use of this code also not my responsibility.  All code provided AS-IS.  I am also going to attempt to link to all the places I found parts of this project but I greatly apologize if I don’t cite your source.  There were a TON of different sources so there is a good chance I will miss someone.

Alright – let’s get this show on the road!

Wiring things up is quite straightforward.  I will mention that I’m using an analog sensor on the breadboard just because I was able to get a free sample here.  I would not recommend using these for your whole project as the voltage drop across the cable runs will cause problems.  I just stuck one with the board because it was free so I figured why not.

Alright connecting the DS18B20 sensors is really easy.  We will be using normal mode (instead of parasitic) as this provides more consistency and allows for longer cable runs.

Pinout:

Schematic:

(I didn’t make these, they came from here)

Additionally if you are connecting up an analog sensor as I did the wiring is a slight bit different:

(source)

Alright so things are wired up, now you need the addresses of the digital sensors.  As I found this wonderful post on obtaining the addresses so I will not cover it in the post.  Please see that post for information on getting the addresses of the sensors.

Here are the files you will need to get started: Zipped Files  Obviously the .ino file needs to be uploaded to the Arduino board after inputting the correct server IP , host, mac, and sensor addresses.  The .sql file needs imported into your database.  The write.php needs edited with your DynamicDNS host if you are doing this from home.  You can sign up for an account here.  You just have to make sure one of the devices on your network is updating the IP address.  Additionally if you are writing to a local web server you can remove this part as it’s merely for security to prevent anyone from writing to the database.  After you have edited this file upload it and the lib directory to your web server.

Assuming everything is working correctly you should start seeing temp and power readings in your database:

At this point you should be good to go.  You can watch the output from the Arduino board on your PC to make sure that things are doing what they are supposed to.  Also the logs on your webserver can be useful if you encounter problems.  Hopefully this post helps someone and please feel free to leave a comment with additions/questions/problems!  Thanks for reading!

Impatience – An Interesting Analysis

So I was doing some data analysis today at work and stumbled upon an interesting “trend” if you can call it that.  While it’s really too early to state anything definitive as I only have 2 data sets what I found really intrigued me.  It seems that we, as a people, have gotten more impatient just in the last 2 years alone.

Some background, I work for an electric company in the Midwest   I’m sure you could figure out where but I won’t mention it in this post.  As all electric companies can attest, outages are a part of life.  There are, however, massive outages that occur from time to time.  Today I analysed 2 such mass outage events, the Ice Storm in February of 2011 and the Derecho hurricane/tropical storm in June of 2012.  I specifically analysed the call volumes we received during these two events spaced roughly a year and a half apart.

Both events lasted about 3 days meaning that from the time the first person lost power to the time the last person’s power was restored was about 72 hours in each case.  Here is where things get interesting though.  I’m going to first post some of my data then go into the analysis of it:

Ice Storm 2011:
7925 total calls
3530 unique numbers
Average 2.25 calls per unique number
Top number called 40 times

Derecho Storm 2012:
10610 total calls
3659 unique numbers
Average 2.90 calls per unique number
Top number called 80 times

The very first thing I would like to point out is the top caller’s number of calls during each event.  They were not the same person, or at least not the same number.  Calling 40 times over 3 days is just crazy, calling 80 times is nearly obsessive.  That’s more than once per hour assuming that they didn’t sleep.  If they did sleep 8 hours per night that’s nearly 1 call every 30 minutes while awake.

Additionally you will notice the average calls per number, 2.25 during the ice storm and 2.90 during the Derecho storm.  This is also shown by the calls vs. unique’s.  The increase in calls from the ice storm to Derecho was about 2600 while the increase in unique numbers was only about 100.     While this doesn’t seem like a massive jump it does show the impatience increase between the two events.  Also there were only 3 numbers that called 20+ times during the ice storm, during Derecho there were 27 numbers that called 20+ times.

I would like to again point out that this observation/analysis is not scientific in any way.  I also do not have decades worth of results to present.  I’m merely pointing out what I noticed while working with this data today, how much more impatient we have become.  Not that I wish to have another massive outage event but I will be very interested to analyse the next one after it happens to see if this is a continuing trend or a one-time thing.

Anyway that is all.  I’m probably more interested by this than anyone else will be.

Fuck you Blendon Square – Westerville Ohio – Don’t Bother!!!

So just saying…this is probably the worst complex I have lived in.  We have been here ~2.5 years; it started off quite nice but it had rapidly deteriorated during that time.  When we moved it in it was pretty laid back.  Kids playing in the “courts”, friendly neighbors, sane rules, etc.

Now it’s “nobody under 14 years old allowed outside without a parent” and all sorts of other bullshit.  I love that they preach the whole “people who leave trash lying around will be fined” but never actually do anything about it.  Same with the vehicles without a parking tag will be towed; in the 2.5 years I have lived here I have seen ONE vehicle towed and I don’t believe it had anything to do with parking in the wrong spot, I think they just needed work on their car.

It’s also awesome that the people who work in the office can’t even get the address straight.  We live at 5477 Woodvale Court West, there is also a 5477 Woodvale Court.  We get mail for them, they get mail for us, etc.  However the PEOPLE THAT WORK IN THE OFFICE delivered a “late notice” to us at “west” that was meant for the “non west” address.  Nice that they can’t even figure that out and we are supposed to?!?!

We are at the point of the neighbors being assholes also.  One blasts this super obnoxious music at all hours and the other seems to be banging hammers against the walls randomly.  I had bricks thrown at, and damage, our front door by a kid who’s mom leaves him in the “care” of his 14-year-old sister who doesn’t give a damn what he does.  This is, best I can tell, common for him but does anyone care?  Nope, not even the complex.

The air-conditioning doesn’t work worth a damn.  Running it full blast all summer just results in a $300+ monthly electric bill and an apartment that is “cool” if it’s under 80 degrees F.  Pretty sure that’s not “normal” as they claim.

Oh and the amount of dust is incredible, if you dust one day there is a good layer of dust on stuff the next day.  I have 2 air purifiers running 24/7 and even at that the pre-filters look like a dryer filter after a few weeks.  It’s insane how much crap is floating around here.

There is also a lot of mold in the basement and even in the kids room from leaking water that seems to be of little concern to them…cause you know…money first people second right?

 Also lovely that we submitted our “Notice to vacate” or whatever the fuck they call it some 2 weeks ago and were supposed to receive a set of forms to fill out but haven’t seen a damn thing.  I’m super tempted to not even give our new address (assuming we actually get something) and let them sort it out.  After the shit we have been though and the small deposit it seems worth it to never hear from them again.

Final note, this will not be published until after we leave.  That means that I’m writing it on 6/11 but it will be a few weeks until you see it.  This is by design.  Hopefully this will steer someone away from this worthless complex and save at least one person the headaches we have faced.  So basically…FUCK YOU BLENDON SQUARE!!!

 

Thanks callmeyng! (and sorry for the trouble)

There is always a lot of hate flying around the Internet and I’m sure that I’m responsible for a bit of it.  However it seems many times people don’t take the time to thank/praise a person or company for a job well done.  Well today I would like to do just that.  As my order was cancelled and a refund given this was the best way I can think to do so.  A few weeks ago I ordered one of these from Amazon fulfilled through callmeyng.  I was very excited to receive it as a replacement tank for one of my tarantula’s, Fluffy.  I had been “turking” to save up the money to get it and placed the order as soon as I had enough.  A few days later it arrived at my office (I don’t ship anything to my house, long story) but as the person that received it set it down I knew something was wrong.  After opening the packaging and pulling it out this is what greeted me:

I snapped that pic and sent it to the seller with a brief description of what I had found.  They responded at once with an apology and a statement that they would be shipping another tank and that FedEx would pick that one up the next day.  FedEx did pick up the tank and a new one arrived a few days later.  It was better packaged with more fragile stickers and wasn’t rattling so I figured I was good to go.  Opened the first box, pulled out the second box, opened it up then pulled out the tank.  I did a quick once-over and found this:

Not nearly as bad but unfortunately still not usable to me.  Sent that picture to the seller and once again they responded at once apologizing saying FedEx would pickup Friday (it was late Wednesday) but that they couldn’t afford to ship a third tank and would simply be refunding the order.  I was rather bummed since I really wanted the tank but understood their position in the matter.  However Friday came and went with no sign of FedEx so I contact again on Monday.  They said that there wasn’t a point shipping it back and that my credit would issue the following day.  Sure enough, around lunch time I got the email from Amazon that a credit had been issued in full including the shipping cost.  So basically, thanks callmeyng and sorry for causing so much trouble.  I hope that this meager post will send a least a little traffic your way to attempt to compensate for the money you no-doubt lost having me as a “customer.”  And in the end, as a seller, you are highly recommend by me and I hope that I can one day purchase something (non-breakable ;-)) from you.  Thanks again.

 

Why I like running my own site

Turns out I learned something today…something I had not expected to learn.  Running your own website may not give you “god-like” status over the Interwebs but it does give you that status for your own site.  It’s a rather…powerful feeling to be able to control what you want displayed on your site.  This is the reason I am not cut out for a position of power in our society.  That is all.

Avoid Dickey’s Barbecue in Delaware Ohio

Today was I think the 5th time I have been here since this re-opened under new management. I have tried to give it a try since the food is pretty good but after my experience today I will not be returning.

After placing our order we were informed that it would be 15-20 minutes for our fried items because they “forgot to turn on the deep fryers.” We said alright and went to sit down. The two of us were offered a drink if we would like and we both accepted to sip on while we waited.

After the 20 minutes was up we approached the register to pay and the total came to $10.50 for each of us. I looked and said well I thought you had given us the drinks. The MANAGER said that the drinks weren’t included in the meal and we would have to pay for them. I then informed him that one of the employees said we could have them while we waited.

He then went on a “rant” about how he was the only one that could make that call and that the other employee didn’t have the authorization to do that. He then, extremely grudgingly, gave us the drinks for free. This is the final event in a series of long waits and meats not being ready for lunch that pushed me not to return.