Web Development Articles

Migrate A CentOS 6 Virtual Server To Another PC Using Virtualbox

There have been a few times where I have needed to migrate a VirtualBox virtual server I have built on one machine to use on another. Usually this is seamless. I simply turn off the server in question, export the appliance to a USB drive or shared folder, import the appliance, and I am all set. This works the same for CentOS 6, except every time that I have done this, the network would refuse to work. I am happy to say I finally found a solution!

After you import the appliance, go into the device settings under network (I always used a bridged adapter), and make sure the device name matches your desired setup. Click Advanced, and refresh the MAC address. Then boot up.

Once booted up, su to root and do the following:

sudo rm -f /etc/udev/rules.d/70-persistent-net.rules

Once rebooted, set your network settings, as needed, to match your network and restart the network service. In my previous attempts, this has fixed the issue.

HTH!

Posted in Linux Tagged with: , ,

Restore Data In MySQL DB from Another MySQL DB

Today a client of mine had an issue where some scripts ran amuck and some data (mainly some timestamp rows) was set to 0. So I had to restore from a backup to fix the issues. The problem is that I couldn’t restore the entire database because today’s data would get lost. It was also only a few columns in a few tables that needed restoring. So here’s what I did.

First, I grabbed a copy of extract_sql.pl, a handy script to have when you want to extract out certain tables from a large MySQL dump file (in this case a 7.7 GB dump file). I used it like this (replace table_name with your table you want to extract):

./extract_sql.pl -t table_name -r daily_backup_2017-03-30_03h00m_Thursday.sql > table_name.sql

I then created a database named `restore` on the same server, and imported the data from the `table_name.sql` file to create and populate the table (my backups include DROP and CREATE statements). Now my `table_name` was in my `restore` database with all of the data up to the last backup.

I then backed up the current table, just in case!

mysqldump -u myuser -p real_database table_name> table_name_backup.sql

Finally, I needed to update just the rows that I wanted, based on conditions in the current database. After searching, I found and modified a solution that worked:

UPDATE
    real_database.table_name live
INNER JOIN
    restore.table_name old ON live.pk = old.pk
SET
    live.add_date = old.add_date,
    live.update_date = old.update_date,
    live.completed_date = old.completed_date
WHERE
    live.add_date = 0

Once I ran the above, all of the data in the restore database updated the data in the live datatbase up to where the backup was made. From there I had to adjust today’s dates, but that was strait forward. I then repeated these steps for each table that needed fixing.

HTH!

Posted in MySQL

Firefox Reports Source File Could Not Be Read

We work on a rather large project that interacts with files stored in the Rackspace Cloud. Users often need to click links to view files saved within orders, and normally this works fine.

Read more ›
Posted in PHP Tagged with: , ,

Hide WordPress Admin Links In Code

Recently on a project the client asked to be able to post testimonials on their site. Normally we install the Testimonials Widget, as it gives us a lot of flexibility, has short codes so we can add to different pages and categorize them, and more. So, in this case, we did, as well, and added a few for them for their approval.

Read more ›
Posted in PHP, Wordpress Tagged with: ,

Redirect All Front-End Pages To Landing Page In WordPress

Today a client of ours announced that they were purchased by another company. Inevitably with this comes website changes, and one change that was needed was to basically phase out the existing corporate website for the purchased company.

Read more ›
Posted in Wordpress Tagged with: ,

Using PHP To Determine SOAP Web Service Parameters

SOAP has been described by many as an easy way to build and consume web services. Up until yesterday, my opinion of that was greatly different. One 3 separate projects, we had found 2 different ways to get it to work properly, none of them the same. On 2 we resorted to using cURL and posting them ourselves! Yikes!

Read more ›
Posted in PHP Tagged with: , , ,