make ES restore script a bit more robust