Improve backup and restore handling