Details
Description
In old Moodles, some of the columns are nullable. Therefore moodle sometimes ends up trying to insert $@NULL@$ into the mdl_user table on restore, which really does not work because some of the colums are VARCHAR(2).
So we need to be calling backup_todb on everything.
However, then you hit the problem that in a clean install of 1.9, all the columns are NOT NULL, so trying to insert NULLs gives errors, so we also need to replace NULL with ''.