truncate file after writing backup/restore bugfix