In my experience you're better off using the native database backup/restore mechanism if you want to retain IDs.
web2py's csv import keeps references but with new sequential IDs as long as you include all the relevant tables in the export. from memory, if you don't want the actual data of a referenced table to be imported you can limit its model to contain no fields at all. (IDs changing is normal for portable databases since IDs are different types depending on the backend. The trick is to never use them in application code or expose them in public URLs email links etc.) --

