Your question can be construed several different ways, and the answer depends on the requirements. Your stated requirement is that build2 should WAIT and run AFTER backup1 if backup1 is running. But what about these?
- A> Allow a SINGLE backup1 to run even if build2 is already?
- B> Allow a SINGLE build2 to run even if backup1 is already running - provided build2 doesn't run again until after backup1 completes?
- C> Is build2 ONLY to be allowed to run AFTER backup1 completes - e.g. as the second of a two-job chain?
- D> Never allow build2 and backup1 to run concurrently?
- E> Allow either (or both) build2 or backup1 jobs to run concurrently.
- F> Which of these jobs do you actually have the power to change?
You need to decide on each of these scenarios in order to accomplish your goal. So lets address D first, because it's the clearest.
There are several ways to make a job not run concurrently with another job. The simplest way is to make them use the same single build resource. (e.g. both jobs use the label BUILDER_SERIAL for which there is only one matching agent, and which allows only a single executor). This pattern creates a Single Point of Failure (SPOF) - if the agent is unavailable the whole chain stalls.
That strategy is one of the methods discussed in How to prevent certain jobs from running simultaneously
However the answers given there also discuss using Lockable Resources - which is a bit cleaner. You then you no longer have an agent as a SPOF, now the failure occurs if the Lock is not properly released. A lock has an advantage, however, in that you can allow one or both jobs to do as much work as they are able and exclude them from doing some "dangerous" things at the same time.
If you are the author of one or both jobs, you can use other jenkins plugins and features, including a pattern I call parasitic, that is you can set up build2 to "Build after other projects are built" and name "backup1" as the monitored job. (This accomplishes the goal C, above)
You can prevent any single job from running more than one build at a time using the 'Do not allow concurrent builds' setting (or use the Throttle Concurrent Builds). This can be done in addition to, or instead of the Single Resource described earlier.