public void Execute(IJobExecutionContext context) { string fileName = DateTimeOffset.UtcNow.Ticks.ToString(); var domains = TenantConvention.GetDomains(); foreach (var domain in domains) { string tenant = TenantConvention.GetDbNameByConvention(domain.DomainName); string directory = this.GetBackupDirectory(domain, tenant); var server = new DbServer(tenant); var agent = this.GetAgent(server, fileName, tenant, directory); try { agent.BackupAsync ( done => { var backup = new Resources(tenant, directory, fileName); backup.AddTenantDataToBackup(); backup.Compress(); backup.Clean(); }, error => { Log.Error($"Could not backup because and error occurred. \n\n{error}"); }) .Wait(); } catch (Exception ex) { Log.Error("Exception occurred executing the backup job. {Exception}.", ex); } } }