Save profile ID when using backup, and use profile ID when restoring

I've tried testing all possible scenarios, but probably forgot something...
Maybe someone should test my version before we merge?
Also, the backup file is a bit less pretty now, but I guess it's something we can live with? :)