Does svnadmin hotcopy lock the source repository during the copy operation?
0 reputation · 30 Apr 2021, 04:16 UTC
0 reputation · 30 Apr 2021, 04:16 UTC
The goal is to move a small Subversion repository to a new server with little or no downtime by creating a hotcopy of the repository on the destination host and then updating working copies to point at the new URL using svn switch --relocate.
The Subversion documentation does not explicitly state whether svnadmin hotcopy acquires an exclusive lock on the source repository that would prevent new commits during the copy, nor does it guarantee that all custom hook scripts are duplicated and remain functional on the hotcopied repository; additionally, it is unclear if clients can have their working copies relocated with svn switch --relocate while the original repository continues to accept transactions without encountering transient errors.
Key questions to resolve are: Does hotcopy block commits on the source repository while it runs? Are all pre‑commit, post‑commit and post‑update hooks copied and executable on the target repository? Can svn switch --relocate be applied to working copies while the source repository stays online without causing commit or update failures?
Running svnadmin hotcopy **does acquire a lock on the source repository** that blocks write operations (commits) until the copy completes. Read‑only operations such as svn update continue normally.
The lock is a file named db/lock in the repository’s root directory. When the file exists, any process attempting to perform a write operation will either block or return a lock error until the file is removed.
The hooks directory is part of the repository tree, so svnadmin hotcopy copies it exactly. On POSIX systems executable bits are preserved, meaning the scripts will run on the destination repository without modification. Windows copies may lose executable permissions; verify by running chmod +x on the scripts if needed.
svn switch --relocate while the original repo remains onlineClients can relocate their working copies to the new URL at any time. As long as the original repository stays reachable, svn switch --relocate performs a simple URL rewrite and does not interfere with ongoing commits or updates.
Verify the repository is in a consistent state (e.g., run svnadmin verify /path/to/repo).
Start the hotcopy on a low‑traffic window:
svnadmin hotcopy /srv/svn/oldrepo /srv/svn/backup/newrepo
While the command runs, any svn commit to the original repo will block or fail with a lock error. Clients can still svn update without interruption.
After the hotcopy finishes, confirm the lock file is removed:
ls -l /srv/svn/oldrepo/db/lock
# should not exist
Test the destination repository’s hooks by performing a dummy commit from a fresh working copy:
svn checkout file:///srv/svn/backup/newrepo wc
cd wc
# modify a file
svn commit -m "Test hook"
Relocate existing working copies to the new URL:
svn switch --relocate http://old-host/svn/oldrepo http://new-host/svn/newrepo wc
Continue normal operations; the original repository will accept commits again once the hotcopy is complete.
hooks/pre-commit runs and returns a non‑zero exit code when expected.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.