Skip to content

Instantly share code, notes, and snippets.

@igorw
Created August 3, 2012 11:39
Show Gist options
  • Select an option

  • Save igorw/3246844 to your computer and use it in GitHub Desktop.

Select an option

Save igorw/3246844 to your computer and use it in GitHub Desktop.
if [ "$1" == "--rollback" ]
then
echo "> Rolling back to the previous version"
ssh -p $port $target "
DIRS=(\`ls $parentDir | grep $childDir-[0-9] | sort -r\`);
if [ \"\${DIRS[0]}\" = \"\" ]; then echo \"! No rollback dir available\"; exit; fi
mv $targetDir $targetDir-tmp
mv $parentDir/\${DIRS[0]} $targetDir
chmod -R +w $targetDir-tmp 2>/dev/null;
rm -rf $targetDir-tmp;
echo \"> Rollback complete (\${DIRS[0]} restored)\""
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment