Evolutionary rescue by compensatory mutations is constrained by genomic and environmental backgrounds