Skip to content

Instantly share code, notes, and snippets.

@justnom
Last active December 23, 2015 09:39
Show Gist options
  • Save justnom/6616331 to your computer and use it in GitHub Desktop.
Save justnom/6616331 to your computer and use it in GitHub Desktop.
Backup linux based Jenkins settings to a Windows computer using PuTTY.
@echo off
:: Directory of Jenkins settings on server
SET JENKINS_DIR=/var/lib/jenkins
:: Directory to save the backup archives to
SET ARCHIVE_DIR=D:\Backups\Jenkins
:: PuTTY session to use for connecting to the Jenkins machine
SET PUTTY_SESSION=my_session
for /f %%i in ('plink -batch %PUTTY_SESSION% "echo $(date +%%F)"') do set DATE=%%i
set "ARCHIVE_FILE=%DATE%_jenkins.tar.gz"
plink -batch %PUTTY_SESSION% "rm -f /tmp/*_jenkins.tar.gz; cd %JENKINS_DIR%; tar -czf /tmp/%ARCHIVE_FILE% *;"
pscp %PUTTY_SESSION%:/tmp/%ARCHIVE_FILE% "%ARCHIVE_DIR%"
plink -batch proxmox_jenkins "rm -f /tmp/*_jenkins.tar.gz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment