One liner for importing multiple SQL files using WP CLI DB command

In some cases, SQL backups break exports into multiple files, usualy by table name.

I wanted to import all the files in one go and figured googled my way to this “one liner”:

for sql in `ls wp_sql`                                                     
Next up is $sql
time wp db import wp_sql/$sql --skip-optimization

How to use this command – Setup:

This assumes that you have exported the files correctly.

  1. Make sure that the directory holding your SQL files are in the root WordPress directory (next to wp-config.php file)
  2. Make sure you’ve changed directory to the WordPress root.
  3. Rename the directory towp_sql or change the name in the script to the name of your directory.
  4. Add each command line by line.

I hope this helps some one.

Other posts you may also enjoy:

What does 6 months paternity leave feel like with 2 babys?

I didn’t want to say much about this as it is not that common, especially here in South Africa. The norm here is three days and some annual leave. When I share that I’m on family responsibility leave and for how long, people usually either respond with excellent or a mild form of disgusted jealousy. I’m am truly blessed to have the privilege of paid leave for such a long time.

6 Months ago Lauren and I started a new Journey: Hosea was born on 27 September 2018. He was healthy and came into the world screaming joining his big brother Judah as a focus of our complete love and affection.

From the get-go, I realized that Judah doesn’t magically become a big boy. I don’t know why I didn’t think of this, but we now have two babies in the house. I can tell you this much. Having another baby in the house is such a big Joy, however soon after we got home, the reality set in and you realize that you and your wife each have a child to look after. I remember the days when one could say, please look after him while I do this or that, no more handing over and taking naps. All we do now is swop children. Each one makes one. The amazing thing is watching them love each other. It’s interesting that these little humans can show so much love and affection.

I can tell you that it doesn’t feel like a massive holiday. You still have a lot of work to do elsewhere. Work with looking after the Kids. Work with helping your wife recover after labor. Work with having family over. Work around the house and work on family health. Time off feels like work. Before you know it, 6 Months is over. Though I’ve had many things to focus on, I had a lot of time to think. I had a lot of time for Blogging and Journalling.

The time off felt like a dream. At times I couldn’t believe that such a perk would even exist. I admire the confidence and the good faith placed on us. There is no obligation to pay anything back should one decide to leave. There were no strange emails from HR.

Time is not a commodity it is a dried up well.

We don’t have time for each other anymore. Providing valuable time with loved ones is one of the best investments any company can make. I’m now more focused on delivering value and making sure others can continually enjoy these benefits.

If you are interested in working at a company that genuinely cares about its humans, prepare yourself to apply to Automattic.

Other Posts you may like:

It doesn’t have to be crazy at work – quick book review

I usually stick to one book and finish it before moving on, but this book grabbed my attention instantly. Firstly because I love the way the authors run their company. They are so unconventional and so intentional at the same time. So I dropped my current book (The Undoing Project) and jumped into this book.

What an amazing book. From it, I hoped to learn more about the philosophy behind running calm companies and teams. The approach affects everything from pricing products, arranging teams, growing the company and even how tonot raise money.

All the chapters are titled around one aspect of how to run a calm company. My favorite chapters were:

  1. Jomo (Joy of missing out)
  2. Promise not to promise
  3. Benefits Who? – Have real benefits not gimicks
  4. Don’t Negotiate Salaries – pay in the top 5% and don’t compromise on that
  5. Don’t cheat sleep – you need the energy to be productive
  6. The trust battery – how to increase trust

Every piece of advice was based on experience and a proven track record. The way the book is written makes it easy to digest.

There was one thing that I didn’t like about this book. They use curse words all the time. I understand the point they try to make but you can use other words with very similar impact, besides this each chapter bring the point across very well.

If you want to run a company or team without all the fluff industries add then you should read this book. If you one day want to start an effective company, you should read this book. If you need more calm in your work-life, go ahead, read this book.

Other posts you may also enjoy:

WP Docker Curl Error

If you are using Docker for WordPress development you may have discovered an issue while trying to connect to your installation from the CLI.

Trying to do any internal API calls normally result in a curl call. In my case I had this annoying error:

cURL error 7: Failed to connect to local.test port 80 Connection refused

The fix ended up being fairly simple after I understood the issue. The main issue was that PHP and the service entry point, nginx, live in separate containers. To add to this, the WordPress hostname in the Database is not the same as the one our docker network container is known by.

The first step here is to see which service are running you must run:

docker-compose ps

Name                       Command                State                        Ports
woocom_elasticsearch_1   /bin/bash bin/es-docker          Up>9200/tcp, 9300/tcp              
woocom_mailcatcher_1     mailcatcher --no-quit --fo ...   Up>1025/tcp,>1080/tcp
woocom_memcached_1 memcached   Up         11211/tcp                                     
woocom_mysql_1  mysqld      Up>3306/tcp                        
woocom_nginx_1           nginx -g daemon off;             Up>443/tcp,>80/tcp      
woocom_phpfpm_1          docker-php-entrypoint php-fpm    Up         9000/tcp                                      
woocom_wpsnapshots_1     docker-php-entrypoint sh - ...   Exit 255   9000/tcp 

The one we are after is *_nginx_1. Look for the one with nginx in the name. This is the domain name your scripts have to use to access the web server when curling your own sites api.

The final step in the process will be to tell WP which one to use when running CLI scripts. To do so add this to your functions.php:

add_filter( 'home_url', function( $url ) {
	if ( defined('WP_CLI') && WP_CLI ){
		$url = str_replace( 'local.test', 'nginx_1', $url );  // replace with your service name and url
	return $url;

Giving Advice Doesn’t Work, I found a better way

I was recently chatting to a friend. He mentioned some area where he was not succeeding . I had the perfect answer. If he’d only follow my advice.

I make this mistake all too often. I can see it in people’s response. They fell insulted or just irritated that I would try to give advice. I do it sincerely but it always backfires.

I realized that Giving People Advice Rarely Works.

I found this helpful, maybe you will too
— Read on

The most gifted books from the tribe of mentors

I read Tribe of Mentors, a year ago, and wrote down all the recommended books. I made notes on these books as I wanted to see if there are commonalities between the things highly successful people read. To no surprise, I found that many of the mentors recommended the same books.

I thought it would be helpful to create a list of the top ten recommended books. This list is in order of most occurrences and according to my naive method for counting and making notes.

I write this mainly for myself. A reminder of books to purchase for my Library. I still believe good books are worth way more than the paper they are printed on and that re-reading books is the key to finding more value from in them.

  1. Man’s search for meaning

2. The rational optimist

3. Poor charlies almanack

4. The alchimist by Paulo Coelho

5. Song of Solomon by Tonin Morrison

6. Open society and its enemies

7. Making sense of people by San barondes

8. Changing on the Job by Jennifer Garvey Berger

9. In over our heads by Robert Kegan

10. The war of art by Steven Pressfield

11. Leadership on the line.

Confusing income potential and wealth

This is more of a mental note for myself. The connection between wealth and income is very obvious, yet we tend to think they are one and the same. I do it all the time.

Let me break it down for myself:

Income should be called by its rightful name: income potential. All employed people have some kind of potential which is promised on contract or merely estimated based on possible growth.

This promise gives us a sense of pride. We even use it to acquire things making promises to others very far into the future (debt).

This promise should not be confused with wealth. Wealth is not a promise. It is the assets we own now. The value we already have. Something we can realize today. Wealth unlike income potential is something we can inherit or build up over time.

Income potential is not guaranteed and wealth mismanaged can disappear. There are certain intangible things that can be considered wealth, the things no-one can take from you.

The sad thing is that people use income potential to acquire more. I’m not in favor of debt, but I understand why people use their potential to acquire things they can’t yet afford.

I constantly need to remind myself of this. In previously disadvantage communities income potential is often mistaken for wealth and this gives individuals a false sense of security. Wealth is not security, but is much safer than a promise.

Other posts you may also enjoy:

5 Quotes to ponder on from Tribe Mentors

I wrote a quick review on the book, A tribe of mentors, but wanted to go into more detail and give you some of the quotes that that really hit home for me. I chose 5 of them to share with you.

I truly found a lot of value in this book. If you are interested, go ahead and read my quick review here and then get a copy for yourself.

1. Perspective and focus:

“It is not what you look at that matters, it is what you see.”

Henry David Thoreau

2. Good decisions:

“Hard choices, easy life, easy choices hard life”

Jerzy Gregory

3. Being true:

“Integrity is the only path where you will never get lost”.

Mike Maples Jr.

4. Hanging around the right people:

“It is the quality of your relationships that determine the quality of your life”

Esther Perel

5. On taking action:

“To avoid criticism, say nothing, do nothing, be nothing”

Elbert Hubbard

One year at the helm of Vim

One year ago I started using an old text editor called Vim. I’m happy to say that I’m still sticking with it. I’m now very comfortable with VIM and more empowered translate Ideas into working solutions.

In this year I’ve become accustomed to working the terminal, embracing the VIM way while realizing that that coding is just one part of the challenge.

Not your IDE

Transitioning from PhpStorm, I desired the same IDE-like features in VIM. After multiple config changes and plugin tests, I had an epiphany: VIM is an editor and that’s it. It is one of the tools in your shed. You combine it with other command line tools to empower an efficient workflow. I believe this is key to making the most of VIM.

With this also comes the realization that tabs, though it looks nice, is not the most efficient way to switch between files. A short list of buffers is the way to go. I always close the editor when I’m done with a task and re-open it for the next one. This ensures that all current buffers are closed and I can start with a low memory footprint every time.

Who Uses Caps Lock anyways?

A common thing in the VIM community is to modifying CAPS LOCK key. As a programmer you don’t really use CAPS LOCK, you will mainly use SHIFT for upper case. Some VIM users take CAPS LOCK as an extra escape and others as another CTRL. I have chosen CTRL as many commands require this button, which is awkwardly placed on my Mac Keyboard.

Hard Times are good for you

One of the first things I embraced was Hard mode. With this activated, VIM disables the arrow keys for navigation and stops you from jumping up more than one line at a time (using h,j,k,l). This pushed me to use other movements. I would argue this to be a must for any VIM beginner. You simply don’t understand how powerful these other movements are until you get used to them. It is excruciating in the begging but the benefits far outweigh the cost. After some time I turned this mode off and used “Hard Time” instead, which works the same but is a little more forgiving.

Undo and try again

Practicing all the time is critical to mastering VIM. By practicing, I mean on the Job training, while you’re working and editing. If you find that you did something and it took too long, or you remember a faster way to do it. Stop, undo and redo it in a more efficient way. This more effecient way becomes the default going forward and you save yourself many many seconds in future. Adding all these ups definitely increases your editing speed.

Another note on this is not to worry about the time it takes to add a shortcut to your config files. Every second you shave off your workflow gets multiplied by how many times you have to repeat the same editing tasks and this is a major win!

Trying not to use so many plugins

The VIM plugin echosstem makes it much easier for newbies feel comfortable and for masters to craft the exact experience they desire.

I discovered that plugins can get in the way just as much as they can help. You need to make sure you really need a plugin before installing it. What I do is try to I try to get away without a plugin to see if I cant modify my VIMRC to do the same thing a plugin does. As a last resort, I’ll use a plugin.

Onwards and Upwards?

I would encourage everyone to learn VIM, but honestly but I understand that not every workflow will benefit from being close to the Command Line.

You are not in a mutually exclusive relationship with your editor. Use the one that’s better for the task at hand. I occasionally jump into Atom ( forgive me VS Code champs ). As Daniel Miessler puts it, the content matters more than the editor.

Let’s not allow our tools to get in the way. These are our weapons of mass impact and ultimately only a means to an end.

Imposters handbook: a quick review

A year ago I read the imposters handbook. It seemed like this book was specifically for people like me. The found himself in the same position I was in: Feeling like an imposter.

I read this book a year ago, but it took me this long to write something about it as I was lacking the daily discipline of working on my blog probably related to the same imposter feeling.

I felt like an imposter and, at times, probably still, but I’m way more confident now after I realized that everyone else feels the same way. The book showed me that feeling like an imposter is normal but that it doesn’t mean that you should continuously take the back seat and let another lead the way as you think you don’t belong.

This book is a great starter for people, like me, who did not do a Computer Science degree. It is a basic introduction to many relevant topics, but you may want to dive even deeper into those that you encounter more often.

You will find topics you may never ever need, but it’s simply nice to be familiar with what these are and that you can smile and nod without blatantly faking it.

A year later I notice that version 2, with Scott Hanselman, is out and it looks promising:imposters_handbook_season2Link to Imposters Handbook Season 2

I would encourage anyone working in technology or with an interest in programming to read this. It has certainly given me a great deal of comfort knowing that I can now understand some CS concepts that evaded me in the past.