Shelter-in-Place Journal, Day 352

My blog runs on a virtual machine on Linode; it’s been very reliable and having a virtual machine lets me do other things than just run the blog. And for $5/month, it’s cheaper than most WordPress hosting sites (though I did have to set up the whole stack myself).

This morning, I got a note from Linode telling me that they will be migrating the virtual machine to a new physical server in a couple of weeks and encouraging me to back it up before that happens, just in case, along with a pointer to their “Reboot Survival Guide”.

One of the steps in the Survival Guide suggests making a backup of all your MySQL databases – they suggest putting the backup into a file whose name includes the date of the backup. The thing that caught my eye was how they suggested getting the date – I’ve always used this formatting string: %Y-%m-%d, which would generate ‘2021-03-03’, a nice, sortable format. But they suggested using %F to do the same thing – much less typing required.

I’d never seen the %F directive before – I tried it on my Mac, and it worked. I tried it on my Linode, and of course it worked there. It even worked in Python 2 and Python 3 on both systems. But when I tried it in Python 2 on our Windows machine, it wasn’t recognized. I installed Python 3 on the Windows machine, and it worked there.

I guess I should still use %Y-%m-%d if I need to write a truly portable program in Python 2. But the odds of my having to do that are very low, and typing %F is much easier!