Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72641

Backup fails with FileNotFoundException


    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • thinbackup-plugin
    • None
    • Jenkins LTS 2.426.2
      ThinBackup plugin 1.18

      This is similar to JENKINS-67479

      Our daily backup process is failing with following message:

      2024-02-01 06:15:52.146+0000 [id=1632163]       SEVERE  o.j.h.p.t.ThinBackupPeriodicWork#backupNow: Cannot perform a backup. Please be sure Jenkins has write privileges in the configured backup path '/var/lib/jenkins/BACKUP'.
      java.io.FileNotFoundException: File system element for parameter 'source' does not exist: '/var/lib/jenkins/jobs/PATH1/jobs/PATH2/branches/PR-1536'
              at org.apache.commons.io.FileUtils.requireExistsChecked(FileUtils.java:2807)
              at org.apache.commons.io.FileUtils.requireFileCopy(FileUtils.java:2838)
              at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:671)
              at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:619)
              at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:569)
              at org.jvnet.hudson.plugins.thinbackup.backup.HudsonBackup.backupJobConfigFor(HudsonBackup.java:457)
              at org.jvnet.hudson.plugins.thinbackup.backup.HudsonBackup.backupJob(HudsonBackup.java:347)
              at org.jvnet.hudson.plugins.thinbackup.backup.HudsonBackup.backupJobsDirectory(HudsonBackup.java:297)
              at org.jvnet.hudson.plugins.thinbackup.backup.HudsonBackup.backupJobsDirectory(HudsonBackup.java:294)
              at org.jvnet.hudson.plugins.thinbackup.backup.HudsonBackup.backupJobs(HudsonBackup.java:268)
              at org.jvnet.hudson.plugins.thinbackup.backup.HudsonBackup.backup(HudsonBackup.java:182)
              at org.jvnet.hudson.plugins.thinbackup.ThinBackupPeriodicWork.backupNow(ThinBackupPeriodicWork.java:90)
              at org.jvnet.hudson.plugins.thinbackup.ThinBackupPeriodicWork.execute(ThinBackupPeriodicWork.java:67)
              at hudson.model.AsyncPeriodicWork.lambda$doRun$0(AsyncPeriodicWork.java:102)
              at java.base/java.lang.Thread.run(Thread.java:829)

      (I have replaced job names with a placeholder of name "PATH" for anonymity)

      The plugin fails to continue because obviously a job folder does not exist anymore. It could have been removed while the plugin was in progress.

      The code in https://github.com/jenkinsci/thin-backup-plugin/blob/thinBackup-1.18/src/main/java/org/jvnet/hudson/plugins/thinbackup/backup/HudsonBackup.java#L452 is relying on


      which is in the commons-io package from Jenkins core. Version 1.18 of the plugin is based on Jenkins version 2.361, which includes commons-io in version 2.11, see the dependency tree (created with maven):

      [INFO] +- org.jenkins-ci.main:jenkins-core:jar:2.361.4:provided
      [INFO] |  +- org.jenkins-ci.main:cli:jar:2.361.4:provided
      [INFO] |  +- commons-io:commons-io:jar:2.11.0:provided

      I think that the problem still is the FindUtils class, which in https://github.com/apache/commons-io/blob/rel/commons-io-2.11.0/src/main/java/org/apache/commons/io/FileUtils.java#L679 is calling the private method requireFileCopy e.g., which throws the "FileNotFoundException", although all public methods are forwarding only "IOException".

      To fix it, I think, we need to extend the methods in HudsonBackup to also throw and in the right places, catch this "FileNotFoundException". A similar fix has been done back in time with JENKINS-67479.

      BTW: In JENKINS-72640 I updated the Jenkins core version to latest LTS to see if a newer version of commons-io might fix the problem. And although it then pulls version 2.13 of the library, this does not change anything, the library still has that same flaw.

      Since we need to fix our installation fastly, I am going to provide a PR.

            stefan_spieker Stefan Spieker
            krulls Stephan Krull
            0 Vote for this issue
            1 Start watching this issue