Upgrading Mysql Dev Server

Currently

An old MySQL server (5.5.40) on an old Debian installation (3.2.63 with Kernel 3.2).

I want to either upgrade Debian to a newer version (maybe reinstallation?) or use Ubuntu 18.04 (currently being discussed in our team).

TODO

First of all, I’m going to dump all databases.

This is done by this script and on the machine directly but could also be run remotely.

#! /bin/bash

# naming timestamp 
TIMESTAMP=$(date +"%F")

# the output directory
BACKUP_DIR="~/db_dumps"

# username and password for mysql connection and mysqldump
MYSQL_USER="user"
MYSQL_PASSWORD="password"

# get the binaries
MYSQL=$(which mysql)
MYSQLDUMP=$(which mysqldump)

# create output dir ifnexists 
mkdir -p "$BACKUP_DIR"
 
# get all dbs
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
 
# iteration with folder and file creation
for db in $databases; do
	echo "dumping $db"
	$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db > "$BACKUP_DIR/$db-$TIMESTAMP.sql"
done

# a spinner while waiting
spin()
{
  spinner="/|\\-/|\\-"
  while :
  do
    for i in `seq 0 7`
    do
      echo -n "${spinner:$i:1}"
      echo -en "\010"
      sleep 1
    done
  done
}

# if gzip parameter is given, gzip all files afterwards
while [[ $# -gt 0 ]] && [[ ."$1" = .--* ]] ;
do
	spin &
	SPIN_PID=$!
	trap "kill -9 $SPIN_PID" `seq 0 15`

    opt="$1";
    shift;
	case "$opt" in
			"--gzip")
				echo "gzipping"
				for file in $BACKUP_DIR/*.sql; do
					gzip $file
				done
				;;
			"--zip")
				echo "zipping"
				for file in $BACKUP_DIR/*.sql; do
					zip -q $file.zip $file
					rm $file
				done
				;;
			"--tar")
				echo "creating tarball"
				for file in $BACKUP_DIR/*.sql; do
					tar -cvf $file.tar $file
					rm $file
				done
				;;
			"--targz")
				echo "creating tarball and gzipping"
				for file in $BACKUP_DIR/*.sql; do
					tar -czvf $file.tar.gz $file
					rm $file
				done
				;;
			*)
				;;
		esac
done

echo "done"
exit 0

And then I’m importing all dumps to a new server, which might not be set up yet.

Read more

A techy Podcast Collection

podcast microphone

image credit @jonathanvez

Disclaimer: None of the following was sponsored or affiliated.

Flash Forward

Flash Forward is a show about possible (and not so possible) future scenarios.

What would the warranty on a sex robot look like? How would diplomacy work if we couldn’t lie?

Could there ever be a fecal transplant black market? (Complicated, it wouldn’t, and yes, respectively, in case you’re curious.)

Hosted and produced by award-winning science journalist Rose Eveleth, each episode combines audio drama and journalism to go deep on potential tomorrows, and uncovers what those futures might really be like.

Read more