从另一个文件系统恢复Jenkins备份

时间:2017-10-04 11:22:06

标签: amazon-web-services jenkins devops

我需要从备份(AWS Snapshot)恢复我的jenkins配置。我有一个EC2实例,跟随并更新,丢失了jenkins配置。我的第一次尝试是将EC2 AMI恢复到更新前的点,但仍然缺少jenkins配置。

我们每晚都会拍摄jenkins的AWS快照。从这里我创建了一个卷并将其安装到EC2盒子上。我将它安装到/media/jenkins/并看到jenkins数据存在。它以37Gb进入。我在实例上重新安装了Jenkins并尝试将/var/lib/jenkins/符号链接到/media/jenkins/但是这会导致Too many levels of symbolic links

jenkins_home是37GB。 jenkins运行的EC2实例只有17 GB免费(它是一个40GB的盒子)。因此,我假设备份中的所有数据最初都不在盒子上。

我的问题是我需要将整个37GB复制到/ var / lib / jenkins /这似乎是一种蛮力的方法,还是有一种更明智的方法来恢复jenkins。

这是我的空jenkins配置

[10:43][ip-10-0-33-8:/var/lib/jenkins[1]]$ ls -la
total 8
drwxr-xr-x  2 root root 4096 Oct  4 12:06 .
drwxr-xr-x 27 root root 4096 Oct  4 11:04 ..

并在备份装载

[10:43][ip-10-0-33-8:/media/jenkins[1]]$ ls -la
total 12
drwxr-xr-x  3 jenkins jenkins 4096 Oct  4 12:10 .
drwxr-xr-x  3 root    root    4096 Oct  4 10:42 ..
drwxr-xr-x 40 jenkins jenkins 4096 Sep 29 16:12 jenkins_home

在jenkins_home里面

[10:26][ip-10-0-33-8:/media/jenkins/jenkins_home]$ ls -la
total 476
drwxr-xr-x  40 jenkins jenkins  4096 Sep 29 16:12 .
drwxr-xr-x   3 jenkins jenkins  4096 Oct  4 12:10 ..
drwxr-xr-x   2 jenkins jenkins  4096 Sep 28 14:35 .apex
-rw-------   1 jenkins jenkins  2948 Aug 17 10:27 .bash_history
drwxr-xr-x   3 jenkins jenkins  4096 Feb  9  2017 .bower
drwxr-xr-x   3 jenkins jenkins  4096 Jan 28  2017 cache
drwxr-xr-x   6 jenkins jenkins  4096 Jul 11 13:36 .cache
drwxr-xr-x   9 jenkins jenkins  4096 Jun 21 15:08 caches
-rw-r--r--   1 jenkins jenkins   252 Aug 16 16:47 com.chikli.hudson.plugin.naginator.NaginatorPublisher.xml
-rw-r--r--   1 jenkins jenkins   120 Jan 29  2017 com.cloudbees.jenkins.GitHubPushTrigger.xml
-rw-r--r--   1 jenkins jenkins   337 Aug 16 16:47 com.smartcodeltd.jenkinsci.plugins.buildmonitor.BuildMonitorView.xml
drwxr-xr-x   6 jenkins jenkins  4096 Aug 17 10:25 .config
-rw-r--r--   1 jenkins jenkins 14794 Sep 25 08:43 config.xml
-rw-r--r--   1 jenkins jenkins     0 Jan 29  2017 Connection Activity monitoring to slaves.log
-rw-r--r--   1 jenkins jenkins  1155 Aug  7 15:29 credentials-configuration.xml
-rw-r--r--   1 jenkins jenkins  4288 Jul 26 11:27 credentials.xml
drwxr-xr-x   3 jenkins jenkins  4096 Jan 28  2017 docs
-rw-r--r--   1 jenkins jenkins     0 Jan 29  2017 Download metadata.log
drwxr-xr-x 258 jenkins jenkins  4096 Jan 28  2017 fingerprints
drwxr-xr-x   2 jenkins jenkins  4096 Jan 29  2017 .fontconfig
-rw-r--r--   1 jenkins jenkins   214 Aug 16 16:47 github-plugin-configuration.xml
drwxr-xr-x   3 jenkins jenkins  4096 Jan 29  2017 .groovy
-rw-r--r--   1 jenkins jenkins   808 Aug 16 16:47 hudson.maven.MavenModuleSet.xml
-rw-r--r--   1 jenkins jenkins   159 Sep 25 08:42 hudson.model.UpdateCenter.xml
-rw-r--r--   1 jenkins jenkins   288 Aug 16 16:47 hudson.plugins.analysis.core.GlobalSettings.xml
-rw-r--r--   1 jenkins jenkins  1521 Aug 16 16:47 hudson.plugins.emailext.ExtendedEmailPublisher.xml
-rw-r--r--   1 jenkins jenkins   322 Aug 16 16:47 hudson.plugins.git.GitSCM.xml
-rw-r--r--   1 jenkins jenkins   370 May 15 16:04 hudson.plugins.git.GitTool.xml
-rw-r--r--   1 jenkins jenkins   688 Aug 16 16:47 hudson.plugins.throttleconcurrents.ThrottleJobProperty.xml
-rw-r--r--   1 jenkins jenkins   523 Aug 16 16:47 hudson.scm.CVSSCM.xml
-rw-r--r--   1 jenkins jenkins   388 Aug 16 16:47 hudson.scm.SubversionSCM.xml
-rw-r--r--   1 jenkins jenkins   145 May 15 16:04 hudson.tasks.Ant.xml
-rw-r--r--   1 jenkins jenkins   626 Aug 16 16:47 hudson.tasks.Mailer.xml
-rw-r--r--   1 jenkins jenkins   571 May 15 16:04 hudson.tasks.Maven.xml
-rw-r--r--   1 jenkins jenkins    76 Aug 16 16:47 hudson.tasks.Shell.xml
-rw-r--r--   1 jenkins jenkins   215 Aug 16 16:47 hudson.triggers.SCMTrigger.xml
-rw-------   1 jenkins jenkins  1680 Jan 29  2017 identity.key.enc
drwxr-xr-x   3 jenkins jenkins  4096 Jan 29  2017 .java
drwxr-xr-x   3 jenkins jenkins  4096 Jan 30  2017 .jenkins
-rw-r--r--   1 jenkins jenkins    94 Jun 29 16:08 jenkins.CLI.xml
drwxr-xr-x   2 jenkins jenkins  4096 Jan 28  2017 jenkins.diagnostics.ooom.OutOfOrderBuildMonitor
-rw-r--r--   1 jenkins jenkins     6 Jan 29  2017 jenkins.install.InstallUtil.lastExecVersion
-rw-r--r--   1 jenkins jenkins     6 Jan 29  2017 jenkins.install.UpgradeWizard.state
-rw-r--r--   1 jenkins jenkins   191 Aug 16 16:47 jenkins.metrics.api.MetricsAccessKey.xml
-rw-r--r--   1 jenkins jenkins   159 Aug 16 16:47 jenkins.model.ArtifactManagerConfiguration.xml
-rw-r--r--   1 jenkins jenkins   138 Jan 29  2017 jenkins.model.DownloadSettings.xml
-rw-r--r--   1 jenkins jenkins   236 Aug 16 16:47 jenkins.model.JenkinsLocationConfiguration.xml
-rw-r--r--   1 jenkins jenkins   247 May 15 16:04 jenkins.mvn.GlobalMavenConfig.xml
-rw-r--r--   1 jenkins jenkins   457 May 15 16:04 jenkins.plugins.shiningpanda.tools.PythonInstallation.xml
-rw-r--r--   1 jenkins jenkins   401 Aug 16 16:47 jenkins.plugins.slack.SlackNotifier.xml
-rw-r--r--   1 jenkins jenkins   310 Aug 16 16:47 jenkins.plugins.slack.webhook.GlobalConfig.xml
-rw-r--r--   1 jenkins jenkins   169 Jan 29  2017 jenkins.security.QueueItemAuthenticatorConfiguration.xml
drwxr-xr-x  87 jenkins jenkins  4096 Sep 14 11:52 jobs
drwxr-xr-x   3 jenkins jenkins  4096 Jan 31  2017 .local
drwxr-xr-x   5 jenkins jenkins  4096 Jan 28  2017 logs
drwxr-xr-x   3 jenkins jenkins  4096 Jan 30  2017 .m2
drwxr-xr-x   5 jenkins jenkins  4096 Jul 14 14:31 .node-gyp
-rw-r--r--   1 jenkins jenkins   911 Sep 25 08:42 nodeMonitors.xml
drwxr-xr-x   5 jenkins jenkins  4096 Sep 30 07:49 nodes
drwxr-xr-x 938 jenkins jenkins 36864 Sep  4 13:57 .npm
-rw-r--r--   1 jenkins jenkins   241 Aug 16 16:47 org.codefirst.SimpleThemeDecorator.xml
-rw-r--r--   1 jenkins jenkins   298 May 15 16:04 org.jenkinsci.plugins.docker.commons.tools.DockerTool.xml
-rw-r--r--   1 jenkins jenkins  1830 Sep 25 08:43 org.jenkinsci.plugins.ghprb.GhprbTrigger.xml
-rw-r--r--   1 jenkins jenkins   255 May 15 16:04 org.jenkinsci.plugins.gitclient.JGitApacheTool.xml
-rw-r--r--   1 jenkins jenkins   243 May 15 16:04 org.jenkinsci.plugins.gitclient.JGitTool.xml
-rw-r--r--   1 jenkins jenkins   290 Aug 16 16:47 org.jenkinsci.plugins.pipeline.modeldefinition.config.GlobalConfig.xml
-rw-r--r--   1 jenkins jenkins    46 Sep 29 15:57 org.jenkinsci.plugins.workflow.flow.FlowExecutionList.xml
-rw-r--r--   1 jenkins jenkins   218 Aug 16 16:47 org.jenkinsci.plugins.workflow.libs.GlobalLibraries.xml
-rw-r--r--   1 jenkins jenkins   367 Aug 16 16:47 org.jenkinsci.plugins.zap.ZAPBuilder.xml
-rw-r--r--   1 jenkins jenkins   185 Aug 16 16:47 org.jvnet.hudson.plugins.SSHBuildWrapper.xml
-rw-r--r--   1 jenkins jenkins  2630 Jan 29  2017 Out of order build detection.log
-rw-r--r--   1 jenkins jenkins    46 Oct  1 00:35 .owner
drwxr-----   3 jenkins jenkins  4096 Jan 30  2017 .pki
drwxr-xr-x   2 jenkins jenkins  4096 Sep 14 14:45 .plotly
drwxr-xr-x 141 jenkins jenkins 20480 Sep  6 13:11 plugins
drwxr-xr-x   2 jenkins jenkins  4096 Aug 11 16:52 .pylint.d
drwxr-xr-x   3 jenkins jenkins  4096 Mar  3  2017 .python-eggs
-rw-r--r--   1 jenkins jenkins 18064 Sep 25 08:42 queue.xml.bak
drwxr-xr-x   3 jenkins jenkins  4096 Jan 30  2017 .qws
-rw-r--r--   1 jenkins jenkins   369 Jun 29 16:08 scriptApproval.xml
-rw-r--r--   1 jenkins jenkins    64 Jan 29  2017 secret.key
-rw-r--r--   1 jenkins jenkins     0 Jan 29  2017 secret.key.not-so-secret
drwx------   4 jenkins jenkins  4096 Jun 29 16:00 secrets
drwx------   2 jenkins jenkins  4096 Jul  3 14:51 .ssh
drwxrwxrwx 522 jenkins jenkins 20480 Sep 28 12:43 temp
drwxr-xr-x   3 jenkins jenkins  4096 Jan 28  2017 test
drwxr-xr-x  16 jenkins jenkins  4096 Jan 28  2017 tmp
drwxr-xr-x   3 jenkins jenkins  4096 Jan 28  2017 tools
drwxr-xr-x   2 jenkins jenkins  4096 Sep 30 08:43 updates
drwxr-xr-x   2 jenkins jenkins  4096 Jan 28  2017 userContent
drwxr-xr-x  77 jenkins jenkins  4096 Sep 18 14:07 users
-rw-------   1 jenkins jenkins   792 May 15 13:05 .viminfo
drwxr-xr-x   2 jenkins jenkins  4096 Jan 28  2017 workflow-libs
drwxr-xr-x 108 jenkins jenkins 12288 Sep 25 01:06 workspace
drwxr-xr-x   2 jenkins jenkins  4096 Aug 16 16:55 .ZAP

1 个答案:

答案 0 :(得分:1)

我认为你应该复制所有37 GB 这个时间。但是为了下一次尝试理解为什么你有37 GB的数据。 你可以忽略它包含的工作区文件夹,只包含要在Master上构建的临时文件。

检查是否存在历史记录太多并存档某些文件的问题构建,也许您可​​以减少数据。

另一种选择是开始使用瘦备份插件 - https://wiki.jenkins.io/display/JENKINS/thinBackup它可以备份所有配置。

另一个备份选项是使用https://wiki.jenkins.io/display/JENKINS/SCM+Sync+configuration+plugin,您可以在Github或任何其他源代码控制中保留所有配置/历史记录。