If you are managing a complex install with many plugins you should use git to manage the codebase. This allows you to upgrade code code with one command, and it will simply add, delete or modify files as need be, and will leave your plugin files alone.
https://docs.moodle.org/310/en/Git_for_Administrators
https://docs.moodle.org/310/en/Git_for_Administrators