by accident / on accident

The standard phrase versus the newer twin of on purpose.

Use by accident. On accident is formed on the pattern of on purpose. It is casual. It is not the standard phrase.

Examples

UseI deleted the file by accident.

UseI deleted the file on purpose.

AvoidI deleted the file on accident.