Created
September 23, 2010 14:14
-
-
Save imyousuf/593670 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
HUDSON_WORK_DIR=/home/hudson/.hudson/ | |
BACKUP_DIR=/home/smartadmin/hudson/backup/ | |
files_to_copy=$(find "$HUDSON_WORK_DIR" | grep -v "^\(.*/\(workspace\|builds\|modules\)/.*\)") | |
( | |
stamp=$(date +%Y-%m-%d'T'%H:%M:%S%z) | |
current_bk_dir="$BACKUP_DIR" | |
mkdir -p "$current_bk_dir" | |
cd "$current_bk_dir" || exit 1 | |
test -d .git || git init | |
for file in $files_to_copy | |
do | |
if test -d "$file" | |
then | |
mkdir -pv ".$(echo $file $HUDSON_WORK_DIR | awk '{ print substr($1, length($2)) }')" | |
else | |
cp -rv "$file" .$(echo "$file" "$HUDSON_WORK_DIR" | awk '{ print substr($1, length($2)) }') | |
fi | |
done | |
git add . | |
git status && git commit -m "Backup of $stamp" -s | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment