Monthly Archives: May 2018

WordPress Backup Script

My WordPress backup script, which keeps daily, weekly and monthly backups of website files and database dumps.

UPDATE: also available at GitLab, Swimgeek Backup Scripts


This should work on your garden variety Debian or Ubuntu server running WordPress and Mysql.

Copy this script to /usr/local/sbin/backup-websites

cat /etc/cron.d/backup-websites
# Backup websites and databases at around 3am
15 03 * * * root /usr/local/sbin/backup-websites

btw. sorry the indentation seems to go missing when I use the /code tag in WordPress.

Obligatory Muppets Photo

The script…


# Backup websites and databases

# Set some variables and paths

# Must contain backup.monthly backup.weekly backup.daily folders

DATABASES=`echo "show databases" | /usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf | grep -v Database | grep -v schema`


# Make appropriate destination directory

# Destination file names
date_daily=`date +"%Y-%m-%d"`

# Get current month and week day number
month_day=`date +"%d"`
week_day=`date +"%u"`

# On first month day do monthly
if [ "$month_day" -eq 1 ] ; then
# On Saturdays do weekly
if [ "$week_day" -eq 6 ] ; then
# On any regular day do daily

mkdir $destination

# latest backup symlink
ln -snf $destination /$BACKUP_DIR/latest

# Create backup files in today's directory

stamp=`date +%Y-%m-%d_%H-%M-%S`

# Dump MySQL tables in incoming dir
for db in $DATABASES; do
/usr/bin/mysqldump --defaults-file=/etc/mysql/debian.cnf $db | bzip2 > \


# Compress files, one tar file per sub directory
for filedir in $FILE_DIRS; do
tar -C / -cjf /$BACKUP_DIR/$destination/$filedir.$stamp.tar.bz2 $FILE_DIRS_BASE/$filedir

# Email backup info

ls -l /$BACKUP_DIR/$destination/ | mail -s "[`uname -n`] Websites Backup $date_daily" $email

# Clean up old backups

# Daily - keep for 7 days
find /$BACKUP_DIR/backup.daily/ -maxdepth 1 -mtime +7 -type d -exec rm -rf {} \;

# Weekly - keep for 30 days
find /$BACKUP_DIR/backup.weekly/ -maxdepth 1 -mtime +30 -type d -exec rm -rf {} \;

# Monthly - keep for 365 days
find /$BACKUP_DIR/backup.monthly/ -maxdepth 1 -mtime +365 -type d -exec rm -rf {} \;


Keep your backups for less time by updating mtime above.

To recover your backups:

tar jxvf your-backup-file.tar.bz2
bunzip2 your-backup-file.sql.bz2


Quick Update

IPv6, Solo, braai…

Mouille Point
  • Week of 21 to 28 May.
  • Monday, rainy day, walked to the office, late afternoon nap, server tinkering, banting wraps.
  • Started the week feeling somewhat inbox zero’ish, for a change.
  • “The more shots you take, the more shots you can take.”

  • On the #DeleteFacebook topic. I also did not see any real dip in friend numbers, but also not seeing any growth in FB friends over the last few months. When last did you see a check-in? Much less photos on FB. I totally removed FB from my phone. No more mobile browser use. I also totally switched off the app platform features: Settings > Apps and websites > Off.
  • Why You’re Wasting Your Life Away – Sam Harris
  • Tuesday, office, dev workshop, improved my website backup script, pipe track walk with Nick, ribs special at Van Hunks with Georg and Anton – collagen meal, irish coffee at Harvey’s with Georg, tested the latest Jolp iOS app, watched The Secret of Monkey Island documentary – very cool.
  • I’ve become a believer in eating lots of diverse foods. I also take a wide range of supplements twice a week.
  • How I know I’ve had a sub-optimal week, I can’t add the “time well spent” flag to any day or I struggle to collect ten photos to post.
  • Wednesday, I enabled IPv6 on a web server for the first time, gym, Cape Town winter special dinner at Srolla with Nick and Michael.
  • IPv6 Excuse Bingo
  • With IPv6 there are almost limitless IP addresses, at two to the power of 128 addresses: 340 trillion trillion trillion. From scarcity to abundance.
  • Streetlight effect: A policeman sees a drunk man searching for something under a streetlight and asks what the drunk has lost. He says he lost his keys and they both look under the streetlight together. After a few minutes the policeman asks if he is sure he lost them here, and the drunk replies, no, and that he lost them in the park. The policeman asks why he is searching here, and the drunk replies, “this is where the light is”.
  • I’ve been listening to The Obstacle is the Way. Pretty good.
  • Thursday, office, lunchtime walk, newsletter writing, Fred’s book launch at Heavy Chef at Workshop 17 – well done Fred, late dinner at Ocean Basket with Heleen.
  • Note to self: hang out with more cool smart people.
  • Friday, work, gym, micro nap, sunset walk to the Waterfront with Heleen, fetched a copy of the Armada book for Mia, 2kg mussels at Den Anker – winter special.
  • Saturday, up early, drove to Jacques’ house, we drove to Hermanus, watched Mia’s hockey tournament – they won the u13B league and received medals (she’s u12), family braai at Rossouw’s house.
  • Sunday, Jacques’ dog woke me up – very cute, we watched Solo at the 3D IMAX – great movie, braai at Jacques’ house, we chased Jacques’ rabbits around the garden, Mia and I visited Moro in Long Street, time well spent.
  • Tune of the week: A-Ha – I’ve Been Losing You

Have a fun week, crazy kids.

Quick Update

I’m just a student, not a guru…

  • Week of 14 to 20 May.
  • Monday, made breakfast for Mia, podcast listening school run, gym, swapped an off-site backup hard drive, work, cooked a mean batch of green veggies and avo, power nap while listening to a podcast, sushi at 1890 with Georg in Obs, a white russian at Harvey’s.
  • Very cool aB after movie.
  • “Never tell me the odds.” — Han

  • I introduced Mia to The Matrix movies. I need to watch them again.
  • Tuesday, nerded out on some new server tech, work, cooked another batch of green veggies, some Jolp app QA, ribs special at Van Hunks with Georg, caught up on some overdue blogging.
  • Worth a watch: Pyramids True Purpose: Advanced Ancient Technology
  • “That one person’s time can belong to someone else is actually quite peculiar.” — You’re Not Just Imagining It. Your Job Is Absolute BS

  • Wednesday, gym – nice sunny winter morning grid area workout, walked to the office, dev meeting, a glass of wine with Nick at Bootleggers.
  • Upgrade your Jolp app and check out the new content. New artwork and playlists.
  • Listen to the two recent interviews with Matthew Walker. Kevin Rose show and Joe Rogan.
  • Thursday, big round of backups, gym, Harvey’s with Warwick and Dirk.
  • My iPhone battery went lame at 23 months, pretty much exactly.
  • Friday, office, dev meeting, oyster special at Sea Breeze with Paul, one drink at Hanks, one tequila at Aces and Spades (yes, really), Sotano.
  • Was reminded of this: “Paul has two settings: Liza Minnelli or Weekend at Bernie’s.”
  • “Eat food, not too much, mostly plants.”, “Take drugs, not too much, mostly psychedelics.” — about Michael Pollan’s new book.

  • Saturday, gym, omelette at Nu, general learning and tinkering, sunset promenade walk – epic sunset, cooked steak and veggies with Heleen.
  • Sunday, backups, more learning and tinkering, notes processing, nap, audio book promenade walk, managed to write a blog post on time – for a change.
  • Enjoy the process of learning.
  • Podcast queue zero again. Time for audio books. Listened to Anything You Want again by Derek Sivers – only 90min, do it.
  • I started listening to Growth Hacker Marketing by Ryan Holiday.
  • Eat more sodium.

Have a fun week, crazy kids.

Quick Update

My hovercraft is full of eels…

  • Week of 7-13 May.
  • Monday, walked to the office, installed a few dev tools, late afternoon promenade walk with Nick, dinner with Heleen.
  • Code founder-run calm companies.
  • I’ve discovered take-away omelettes at Woolworths.
  • Tuesday, work, gym, catch up with Jonathan, Anton’s house to fetch my wallet, Tuesday ribs special at Van Hunks with some white russians – dining alone again, La Vie with Heleen.
  • I went three days without my wallet. Did not really miss it. Smartphones are pretty useful.
  • “Courage is a love affair with the unknown.” — Osho

  • Protect the nerds
  • My skeertuig is vol palings
  • Wednesday, office, dev meeting, catch up with Nick and Michael at Bootleggers.
  • I installed the Jolp app for two security guards this week.
  • Thursday, gym, Green Point Park, office, sunset promenade walk, Mexican food at Heleen’s house.
  • Placebo is the most powerful force in medicine.
  • Friday, office, fetched Mia, biltong shopping, watched Avengers: Infinity War at the Waterfront VIP cinemas – nothing special, but the ending was a bit different, book shop, I convinced Mia to eat a salad at Col’caccios in Camps Bay.
  • Listen to this a16z episode about education: The Case Against Education.
  • In summary: we want vocational education with prestige. A bit like YC – prestige for hacker culture.
  • Saturday, Granger Bay Market with Mia – less crowded than usual, a walk around the Waterfront, book shop, 50min Facetime Audio chat with Jacques, upgraded the home wifi and swapped out a hotspot, drove to Noordhoek via Chapmans, chicken + sundried tomato + avo pizza at The Red Herring – memories from having that there around 2003 with Ernst, night cap at Harvey’s while Mia shopped laptop covers on Amazon.
  • How cool is that Buzz Lightyear Apple Watch face?
  • Sunday, Mia managed a 12h sleep, notes and photo processing, tea and grapefruit, device backups, brunch at gym – gluten free flapjacks, grid area, great swim, Green Point Park, we watched The Dark Knight.
  • Woke up from a dream with a Counting Crows song in my head.
  • Tune of the week: Counting Crows – Round Here – I would link to the music video, but it seems super lame. The words of the song are much better imagined. (Side note: play Mr Jones at my funeral one day.)

Have a fun week, crazy kids.

Quick Update

Multi Pass…

  • Week of 30 April to 6 May.
  • Yeah, this post is late.
  • Learn, create, repeat.
  • Monday, school holiday, made omelettes with Mia, drove to Botrivier, Endless Vineyards Boutique Lodge at Wildekrans Wineyards, afternoon hike with Mia, pink g&t and pizza at Forage with Mia and Heleen.
  • Tuesday, public holiday, morning walk around the farm, extended breakfast, drove to Somerset Mall and found Mia some clothes, hair cut, wine tasting and cheese board at Uva Mira, a late afternoon walk around The Lord Charles Hotel garden, oversized chess game on the lawn – which I won, happy hour at St Andrews Pub, dinner at La Vigna while processing photos and notes – and Mia browsed her 17k kids photos, fun adventure.
  • Wednesday, hotel breakfast at The Lord Charles with Mia, short school run, catch up with Dirk at Waterstone WW Cafe, back to Cape Town, work, drinks at Bootleggers with Nick and Michael, notes processing and blogging.
  • Thursday, gym, walked to the office, dev meeting, lunchtime walk around Sea Point, read a batch of articles and stories about Larry Harvey, happy hour at Burger and Lobster with Paul, Tammy and Darryn’s going away drinks at Tigers Milk – off on a remote working adventure – very cool, Anton’s house.
  • “Belief is thought at rest.” — Larry Harvey

  • I remember going to one of Larry’s talks in 2015.
  • I was kinda in the news this week.
  • Law of Reversed Effort
  • Code calm companies.
  • Friday, office, Startup Chile: negative, dinner with Heleen.
  • Saturday, gym, pre-drinks at Tigers Milk, Goldswindler J00F Fifth Element party at Reset (old ERA) with Georg, Anton and Ollie, great fun – we all had Corbin Dallas tops on and I made a Multi Pass, 35k steps, time well spent – thanks for organising Georg!
  • Old school 90s clubbing.
  • Sunday, Anton’s house, Georg’s house, beach walk from Clifton 1 to 4 and back, chilled afternoon on the beach with Georg, pizza on the beach with Georg and Heleen.

Have a fun week, crazy kids.

Quick Update

Long weekend, rain, omelettes…

  • Week of 23-29 April.
  • Monday, rainy day, walked to the office, watched Tom Raider at the Waterfront – not bad, Mexican food at Heleen’s house.
  • “You can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something – your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.” — Steve Jobs

  • This is gold: Raccoon Crushed To Death By Garbage Truck Hits Jackpot With Reincarnation
  • Tuesday, work, gym, extended promenade walk with Nick, ribs special at Van Hunks with Georg.
  • The Cape Town water crisis in short: The city’s population doubled with no extra water infrastructure projects developed by national government over the last 30 years. Planning for the Berg river dam began in 1989. It’s the most recent water infrastructure project and holds about 14% of Cape Town’s water resource. 100% growth in population with 14% growth in water resource. We had less rain than usual for three years – but this was predicted for years. Local government did nothing and had no plan. They made it seem like the solution was for residential users to use 50 litres per person per day – while agriculture was using a big share of the remaining water. Fear, uncertainty, doubt. Really bad communication from the City of Cape Town. Very late and weak plans to invest in desalination (which probably failed because of mismanagement). Then, recently… agriculture stopped using the remaining water resources and it started raining again. Problem solved? Hmm. Well, now people leave the loo yellow, and many houses have greywater systems, and ways to collect rain water. All in all, probably a good thing to have changed people’s habits around water use, but… it’s clear government is useless and the problem is not going to go away.
  • “It’s significant because the crisis was actually precipitated by a standing ruling that farmers were entitled to 60% of the water from the THEEWATERSKLOOF dam and 40% for human consumption. While there was unrestricted consumption by people, the agricultural sector simply matched that consumption by drawing on their former 60% entitlement unendingly. In the face of imminent depletion of the reservoirs, the water bureaucrats were forced to reevaluate the 6/4 ratio allocation policy. This policy blindly placed agricultural consumption before human consumption.”

  • Wednesday, walked to the office, dev meeting, lunchtime walk, nap, dinner at Heleen’s, lots of rain!
  • The incentives always win.
  • “Moderation is the only thing worth doing in moderation.”

  • Thursday, gym, omelette with Dirk, fetched Mia, drove to Cape Town, took a walk at the end of the cable car road, giant mushroom burger in a bowl at Da Vinci’s, ice cream at Moro in Long Street, time well spent.
  • Be more productive.
  • The struggle for interestingness.
  • When did you get these technologies? It’s probably been more eventful than you remember. Always on internet: 1999, ADSL: 2002, Macbook: 2003, WiFi: 2003, Linux Virtual Machines: 2005, WordPress: 2006, Facebook: 2007, iPhone: 2011 (a bit late maybe), SSD and retina screen: 2015, Gigabit fibre at home: 2017.
  • Friday, public holiday, Waterfront, gluten free carrot cake, clothes shopping for Mia, sunset promenade walk, watched The Dark Knight Rises again on Netflix – great movie.
  • Life is about acceleration, not speed.
  • Saturday, world championship 4 egg decadent exotic mushroom omelette cooking, Cape Town city walk with Mia, kombucha at the Labia to start our walk, coffee at the Company Garden Cafe, down Long Street, Bloody Mary at the Grand Daddy rooftop bar, soccer fan-walk bridge, De Waterkant, shoe shopping for Mia – found her a pair of size 8 trail running shoes, sunset drinks and snacks at Heleen’s house with Georg.
  • RIP Larry Harvey
  • Sunday, De Wetsbaai day with Georg and Mia, braai with Anton and Anton, perfect weather, great sunset, La Vie, time well spent.
  • Going to J00F?

Have a fun week, crazy kids.