refactor backup/restore