public void Backup() { foreach (ReplicationDatabase replicationDatabase in replicationServer.ReplicationDatabases) { if (replicationDatabase.HasPublications) { foreach (TransPublication TP in replicationDatabase.TransPublications) { TextWriter tw = new StreamWriter(dirPath + TP.DatabaseName + @"-" + TP.Name + @".sql"); tw.Write(TP.Script(ScriptOptions.Creation | ScriptOptions.IncludeAll ^ ScriptOptions.IncludeReplicationJobs)); tw.Close(); } } } }