private void EnsureSiteDirecory() { var sitepath = GetSitePath(); if (!ImpersonatedFiles.Exists(sitepath)) { ImpersonatedFiles.CreateDirectory(sitepath); } }
public DefaultResult ReceiveAndSendMessage(CreateBackupRequest message) { try { Logger.Info("Starting Backup"); var site = GetWebsite(); if (site == null) { Logger.Info($"Could not find Site {message.SiteName}"); return(new DefaultResult { Success = false }); } var sitePath = site.Applications["/"].VirtualDirectories["/"].PhysicalPath; Logger.Info($"Found Site Content at {sitePath}"); var backupPath = GetDeploymentPath(); Logger.Info($"Creating Backup at Deployment Location: {backupPath}"); if (!ImpersonatedFiles.Exists(backupPath)) { Logger.Info($"Could not Find New Version of Site"); ImpersonatedFiles.CreateDirectory(backupPath); Logger.Info($"Copy Old Site to Deployment as initial Version"); } ImpersonatedFiles.CopyFilesRecursively(sitePath, backupPath); Logger.Info("Finished Backup"); return(new DefaultResult { Success = true }); } catch (Exception e) { Logger.Error(e); } return(new DefaultResult { Success = false }); }
private void CopyContents() { if (_previousSitePath != GetSitePath() && !string.IsNullOrWhiteSpace(_previousSitePath)) { Logger.Info("New Version of Site due to Path-Change detected"); Logger.Info($"Old Path: {_previousSitePath}"); Logger.Info($"New Path: {GetSitePath()}"); Logger.Info($"Searching for new New Version at Deployment Location {GetDeploymentPath()}"); if (!ImpersonatedFiles.Exists(GetDeploymentPath())) { Logger.Info($"Could not Find New Version of Site"); ImpersonatedFiles.CreateDirectory(GetDeploymentPath()); Logger.Info($"Copy Old Site to Deployment as initial Version"); ImpersonatedFiles.CopyFilesRecursively(_previousSitePath, GetDeploymentPath()); } Logger.Info($"Copy Site from Deployment to local"); ImpersonatedFiles.CopyFilesRecursively(GetDeploymentPath(), GetSitePath()); Logger.Info($"Finished Copy Site"); } }