Reference: I have recently performed version library migration and automatic backup. I have found some related information on the Internet, but they are all messy. I believe many netizens will encounter the same problem, based on my own sorting and practical results, I have summarized a set of feasible (verified) solutions. I plan to share them with you through two blogs for your reference.
I. business objectives
1. Without changing the content and version number of the original version library, all version libraries originally distributed on multiple servers will be migrated to the new version library on one server.
2. implement regular and automatic backup of the new version library.
Ii. Related commands
1. svnadmin dump command syntax
Svnadmin dump repository_path [-r lower [: Upper] [-- incremental]
(1) The svnadmindump command is used to export the revision of a range in the entire repository or repository.
(2) parameter description:
Repository_path is the version library path,
[-Rlower [: Upper] is used to specify the scope of the exported revision, which consists of the-R parameter and two Arabic numbers separated by the: sign.
For example,-R 0: 100 indicates that all revisions between version 0 and version 100 are exported.-R is short for revision.
-- Incremental, which uses incremental mode to export versions, that is, only modifications since the previous version are exported each time. The first advantage is that you can split a large file into several small files. Second, if the version library already exists, we only need to export the modified part each time, and do not need to export the content of the entire version library every time. You can even use the hook script to automatically dump the modifications of the day every night for backup.
2. svnadmin load command syntax
Svnadmin load repository_path
(1) The svnadminload command is used to import version libraries from standard input streams or other streams,
(2) parameter description:
Repository_path is the target version library to be imported.
3. Dump and load output/inbound redirection
Svnadmin dump oldrepository> dumpfile
Svnadminload newrepository <dumpfile
By default, the dump and load commands are output to the default output device (screen) and imported from the default input device (keyboard. However, we can also redirect the output stream/input stream. For example, the first command above uses the redirection character> to direct the screen output to the dumpfile in the current directory, while the second command imports the dumpfile from the current directory.
4. Merge the export and import operations.
Svnadmin dump oldrepository | svnadmin load newrepository
5. svndumpfilter
Used to specify only those projects, not other projects
Ii. migrate the version Library (solution example)
Solution 1: one full migration.
First, create three new batch processing documents (New notepad, suffix changed to. BAT)
① Export. bat
Svnadmin dump oldrepository> dumpfile
② Create a version library. bat
Svnadmin create newrepostitory
③ Import. bat
Svnadmin load newrepository <dumpfile
Steps:
If your SVN is installed in c: \ Program Files, then:
A. Place "export. Bat" in the original library directory, that is, the directory where oldrepository is located (for example, D: \ repositories), double-click it, and export the version library!
B. Put "New Version library. Bat" in the directory of the new database, that is, the location where newrepostitory is to be placed (for example, E: \ repositories), double-click it, and create a new version library!
C. Put "import. Bat" under the new library directory (for example, E: \ repositories), double-click it to import the version library!
If your SVN is not installed in the above position, then:
All the three batch files must be placed in the bin directory of the svn installation directory, and the file name cannot be simply written. The complete file name must be written.
For example, svnadmin dump D: \ SVN version library \ oldrepository> D: \ dumpfile
Note: The above steps achieve lossless migration of the oldrepository version library to newrepository. This is in the form of a batch file. You can complete the above operations in the form of a command in the Command Prompt window. Note that the operation must be performed in the corresponding directory.
Solution 2: incrementally migrate version libraries in batches.
① Check the latest version number of the current old version Library
In the Command Prompt window, open the directory where the library is located, for example, cd d: \ repositories.
Run svnlook youngest oldrepositories
For example, the returned version is 281.
② Incrementally export version Library Content in batches
D: \ repositories \ svnadmin dump oldrepository-R 0: 100> dumpfile1
Export the first version from 0 to 100.
D: \ repositories \ svnadmin dump oldrepository-r 10:200 -- incremental> dumpfile2
Export the second file, version from 101 to 200
D: \ repositories \ svnadmin dump oldrepository-r 201: 281 -- incremental> dumpfile3
Export the revised version of the third file from 201 to 281.
Note: In the three commands, the second and second commands have one more -- incremental parameter, so that they are exported in incremental mode,
③ Import version library files in batches
Note: Open the directory of the version library to be imported, such as cd e: \ repositories.
First import dumpfile1, then dumpfile2, dumpfile3
Run
E: \ repositories \ svnadmin load newrepository <dumpfile1
E: \ repositories \ svnadmin load newrepository <dumpfile2
E: \ repositories \ svnadmin load newrepository <dumpfile3
The following error may occur: The version library file already exists. Check whether the -- incremental parameter is used during the front-end export.
Note: This is done in the Command Prompt window. Similarly, we can write batch files according to solution 1.
Note: write commands based on your SVN installation directory and library directory, for example:
C: \ Program Files \ visualsvn Server \ bin \ svnadmin load D: \ repositories \ newrepository <E: \ dumpfile1
Solution 3. Filter version database history by database sharding or other processing operations during import after export.
Assume that there is a version library oldrepository that contains three projects: project1, project2, and project3. Their layout in the version library is as follows:
/
Project1/
Trunk/
Branches/
Tags/
Project2/
Trunk/
Branches/
Tags/
Project3/
Trunk/
Branches/
Tags/
Now we need to transfer these three projects to three independent version libraries.
① Use solution 1 described above to export the entire version Library:
Svnadmin dump oldrepository> dumpfile
② Send the dumped file three times to the filter. Each time you keep only one top-level directory, you can get three dumped files:
Cat dumpfile | svndumpfilter include project1> 1-dumpfile
Cat dumpfile | svndumpfilter include project2> 2-dumpfile
Cat dumpfile | svndumpfilter include project3> 3-dumpfile
Note: cat is the Subversion document. The command about svndumpfilter is not provided in Windows. The Command similar to cat is type. You can use typedumpfile | svndumpfilter include project1> 1-dumpfile.
③ Each of these three dump files can be used to create an available version library, but they retain the exact path structure of the original version library.
That is to say, although project1 currently excludes a version library, the version library still retains the top-level directory named project1. If you want the trunk, tags, and branches directories to be directly located in the root path of the version library, you may need to edit the dump file and adjust the node-path and copyfrom-path header parameters, delete the path project1.
Delete the project 1 directory created in the dump data. This is generally the following content:
Node-path: project1
Node-Action: add
Node-kind: Dir
Content-Length: 0
Note: When manually editing the dump file to remove a top-level directory, do not let the editor convert the line break to a local format (for example, convert \ r \ n to \ n ), it is easy to cause the dump file to become invalid.
④ Finally, we can use the method provided in solution 1 to import the three dump files separately:
Svnadmin create project1
Svnadmin load project1 <1-dumpfile
Svnadmin create project2
Svnadmin load project2 <2-dumpfile
Svnadmin create project3
Svnadmin load project3 <3-dumpfile
This is the solution for migrating version libraries. In the next blog, we will introduce the solution for regular automatic backup of version libraries.