fix(upgrade): safe copy file and remove