Last active
December 23, 2015 09:39
-
-
Save justnom/6616331 to your computer and use it in GitHub Desktop.
Backup linux based Jenkins settings to a Windows computer using PuTTY.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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