How to correctly copy Jenkins directories from the command line?

Article ID:216114868
1 minute readKnowledge base

Issue

Incorrectly copying Jenkins instances can break job symlinks.

This can cause DirectoryNotEmptyException and permalink errors in the logs and prevent job history from loading correctly, even causing job builds to fail.

Environment

  • Linux

Resolution

Copying Jenkins directories to new location on same instance

cp -Rp SOURCE TARGET

The -R switch is for recursive and the -p switch ensures that links are preserved.

Copying Jenkins directories to new location on different instance

rsync -avz -e ssh /src/dir user@remote.host:dst/dir

NOTE Do not use scp to copy Jenkins to another instance as scp does not preserve symlinks.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.