In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the method of Jenkins backup and recovery". In the daily operation, I believe that many people have doubts about the method of Jenkins backup and recovery. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "Jenkins backup and recovery method". Next, please follow the editor to study!
Preface
Jenkins is an open source tool written in Java language. The application of continuous integration and continuous delivery related technologies can improve the automation level of the software development process.
Jenkins installation from the beginning to permission settings, plug-in installation, task maintenance is a laborious project, so the importance of backing up data on a regular basis is self-evident.
In this article, we will demonstrate hand-in-hand how to back up and restore Jenkins.
Backup operation guide
Step1: create a new task
The free-style task type, Freestyle project, is recommended here.
Step2: select None for source code management
Step3: set task execution time
Select "Build Periodically", then you can set the backup time and frequency as needed
For example, 25 12 * will run the task at 12:25 every day
Add "Execute Shell" to Step4:Build module
Select Execute Shell in the Build module and add the following script content
For the convenience of readers, the content of the script is as follows:
#! / bin/bash # Jenkins Configuraitons Directory cd $JENKINS_HOME # Add general configurations, job configurations, and user content git add-- * .xml jobs/*/*.xml userContent/* ansible/* # only add user configurations if they exist if [- d users]; then user_configs= `ls users/*/ config.xml`if [- n "$user_configs"] Then git add $user_configs fi fi # mark as deleted anything that's been, well, deleted to_remove= `git status | grep "deleted" | awk'{print $3} '`if [- n "$to_remove"]; then git rm-- ignore-unmatch $to_remove fi git commit-m "Automated Jenkins commit" git push-Q-u origin master
Step5: save the above settings
Step6: initializes the local git repository
We have now added a task to back up all Jenkins data, and all backup data will be stored in the server's / var/lib/jenkins directory.
If you currently have a user name of jenkins, enter this directory and execute the following command
Cd / var/lib/jenkins & & git init
Step7: GitHub associated with the local warehouse
Git remote add origin git@github.com:username/new_repo
Step8: test whether the backup task is in effect
On the Jenkins task home page, click the Build now button. If you see the following output, the backup task has been successfully created and takes effect.
Operation guidelines for data recovery
Step1: clear the Jenkins home directory
Cd / var/lib/jenkins & & rm-rf *
Initialize the Step2:Jenkins home directory into a git repository
Cd / var/lib/jenkins & & git init
Step3: recursively clear files that are not under version control
Git clean-df
Step4: add a new remote warehouse address
Git remote add origin git@github.com:username/new_repo
Step5: backing up data from GitHub pull
Git pull origin master
Step6. Restart Jenkins with a root account
Service jenkins restart
At this point, the data has been fully restored.
At this point, the study of "the method of Jenkins backup and recovery" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.