Loading

Quipoin Menu

Learn • Practice • Grow

jenkins / Backup and Restore
tutorial

Backup and Restore

Jenkins stores all configuration, job definitions, build logs, and plugins in the JENKINS_HOME directory. Losing this directory means losing everything. Regular backups are essential.

What to Back Up

The entire JENKINS_HOME directory. Key subdirectories:
  • jobs/ – job configurations and build logs.
  • users/ – user accounts.
  • plugins/ – installed plugins.
  • config.xml – system configuration.
  • credentials.xml – encrypted credentials.
  • secrets/ – internal secrets (do not lose!).

Simple Backup Using ThinBackup Plugin

The "ThinBackup" plugin provides scheduled backups. Install it, then go to "Manage Jenkins" → "ThinBackup". Configure:
  • Backup directory (e.g., /var/backups/jenkins).
  • Schedule (cron expression).
  • Number of backups to keep.
Then run "Backup Now" manually to test.

Manual Backup

Stop Jenkins (to ensure consistency), then copy JENKINS_HOME to a safe location.
sudo systemctl stop jenkins
sudo tar -czf jenkins-backup.tar.gz /var/lib/jenkins
sudo systemctl start jenkins

Restoring from Backup

1. Stop Jenkins.
2. Replace JENKINS_HOME with the backup content.
3. Start Jenkins. Ensure file permissions are correct (ownership jenkins:jenkins).

Backing Up Jenkins Configuration as Code (JCasC)

The "Configuration as Code" plugin allows you to store Jenkins configuration as YAML. You can version it in Git and use it to recreate Jenkins automatically. This is the modern, declarative approach.


Two Minute Drill
  • JENKINS_HOME contains everything – back it up.
  • Use ThinBackup plugin for scheduled backups.
  • Stop Jenkins for consistent manual backup.
  • Test your restore process periodically.

Need more clarification?

Drop us an email at career@quipoinfotech.com