File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,13 +22,15 @@ will be accomplished is in the integration test method [ProgressiveRestore](test
2222You can currently use the CLI to create a copy of a database from one AG to another. It will take a log backup,
2323then restore from the existing backup chain to the new database. If a database exists in the destination AG
2424it will delete it and proceed with the copy.
25+
2526```
26- AgDatabaseMove.Cli --From:ConnectionString="Server=SourceDatabaseListener.domain.com; Integrated Security=true; MultiSubnetFailover=true;"
27- --From:DatabaseName=sourceDbName
28- --From:BackupPathTemplate="\\NetworkShare\{0}_backup_{1}.trn"
29- --To:ConnectionString="Server=DestinationDatabaseListener.domain.com; Integrated Security=true; MultiSubnetFailover=true;"
30- --To:DatabaseName=DestinationDbName
31- --Overwrite=true
27+ AgDatabaseMove.Cli.exe
28+ --From:ConnectionString "Server=SourceDatabaseListener.domain.com; Integrated Security=true; MultiSubnetFailover=true;" --From:DatabaseName test --From:BackupPathSqlQuery "SELECT '\\NetworkShare\path\here'"
29+ --To:ConnectionString "Server=SourceDatabaseListener.domain.com; Integrated Security=true; MultiSubnetFailover=true;" --To:DatabaseName test
30+ --Overwrite true
31+ --Finalize true
32+ --CopyLogins true
33+ --DeleteSource false
3234```
3335
3436## Contributing
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ internal class MoveArgs
1212 public bool Overwrite { get ; set ; } = false ;
1313 public bool Finalize { get ; set ; } = true ;
1414 public bool CopyLogins { get ; set ; } = true ;
15+ public bool DeleteSource { get ; set ; } = false ;
1516 }
1617
1718 internal class Program
@@ -29,6 +30,7 @@ private static void Main(string[] args)
2930 Overwrite = arguments . Overwrite ,
3031 Finalize = arguments . Finalize ,
3132 CopyLogins = arguments . CopyLogins ,
33+ DeleteSource = arguments . DeleteSource ,
3234 FileRelocator = filename =>
3335 RestoreFileRelocator ( arguments . From . DatabaseName , arguments . To . DatabaseName , filename )
3436 } ) ;
Original file line number Diff line number Diff line change @@ -25,5 +25,10 @@ public class DatabaseConfig
2525 /// <example> SELECT Backup_path FROM [msdb].[dbo].[_Sys_Backup_config]</example>
2626 /// </summary>
2727 public string BackupPathSqlQuery { get ; set ; }
28+
29+ public override string ToString ( )
30+ {
31+ return $ "{ ConnectionString } \n { DatabaseName } \n { BackupPathSqlQuery } \n ";
32+ }
2833 }
2934}
Original file line number Diff line number Diff line change @@ -67,12 +67,13 @@ private string AgName()
6767 /// <returns>A DefaultFileLocations object which contains default log and data directories.</returns>
6868 private DefaultFileLocations DefaultFileLocations ( )
6969 {
70- var query =
70+ const string query =
7171 "SELECT SERVERPROPERTY('InstanceDefaultDataPath') AS InstanceDefaultDataPath, SERVERPROPERTY('InstanceDefaultLogPath') AS InstanceDefaultLogPath" ;
7272
7373 using var cmd = SqlConnection . CreateCommand ( ) ;
74- using var reader = cmd . ExecuteReader ( ) ;
7574 cmd . CommandText = query ;
75+ using var reader = cmd . ExecuteReader ( ) ;
76+
7677 if ( ! reader . Read ( ) )
7778 return null ;
7879
You can’t perform that action at this time.
0 commit comments