Example #1
0
        private void RestoreAtDateExecute(ServerAccess ba, SqlServerAccess sa, FileInfo f, string dbName, RestoreOption opt)
        {
            try
            {
                using (new NetworkConnection(ba.uri, new NetworkCredential(ba.username, ba.password)))
                {
                    var filePath = f.FullName;
                    using (new NetworkConnection(sa.uri, new NetworkCredential(sa.username, sa.password)))
                    {
                        string destPath = Path.Combine(sa.uri, sa.folder, f.Name);
                        if (File.Exists(destPath))
                        {
                            File.Delete(destPath);
                        }
                        File.Copy(filePath, destPath); var bakFilePath = destPath;
                        destPath = destPath.Replace(sa.uri, sa.disk);

                        SMOHelper restoreInstance = new SMOHelper(sa);
                        restoreInstance.Restore(destPath, dbName, opt);
                        if (File.Exists(bakFilePath))
                        {
                            File.Delete(bakFilePath);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
            }
        }
Example #2
0
        public string Opt_Restore()
        {
            if (!IsAdmin)
            {
                return("没有权限");
            }

            string backupName = Request["backupName"];

            SMOHelper.Restore(backupName);
            return("操作成功");
        }