{"id":104,"date":"2009-10-27T21:39:17","date_gmt":"2009-10-27T20:39:17","guid":{"rendered":"http:\/\/webpiraten.de\/?p=104"},"modified":"2010-01-27T10:19:18","modified_gmt":"2010-01-27T09:19:18","slug":"deployment-mit-an","status":"publish","type":"post","link":"https:\/\/webpiraten.de\/index.php\/linux\/deployment-mit-an\/","title":{"rendered":"Deployment mit ANT"},"content":{"rendered":"<p>ANT ist ein wunderbares Kommandozeilen-Tool mit dem man Deployment gerade auch von Webapplikationen automatisieren kann.<\/p>\n<p>Ich benutze es um Entwicklungsst\u00e4nde in die Stage oder Liveumgebung auszuspielen.<\/p>\n<p>Zur Konfiguration des Deploymentprozesses erzeugt man eine <strong>build.xml<\/strong> Datei, die alle n\u00f6tigen Anweisungen enth\u00e4lt.<\/p>\n<p>Folgende XML Datei erzeugt einen Backup-Ordner und kopiert die aktuelle Live-Applikation dort hinein.<\/p>\n<p>Desweiteren erzeugt das Skript einen Datenbank Dump und kopiert diesen ebenfalls dorthin.<\/p>\n<p>Danach wird der aktuelle Entwicklungsstand in den Live-Ordner kopiert.<\/p>\n<p>Zu guter Letzt werden noch die Log- und Cache-Ordner geleert.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\n&lt;project name=&quot;builder&quot; default=&quot;build&quot; basedir=&quot;.&quot;&gt;\r\n    &lt;description&gt;\r\n        devel to live update including dbdump and clear cache\r\n    &lt;\/description&gt;\r\n\r\n    &lt;!-- set global properties for this build --&gt;\r\n    &lt;property name=&quot;devel&quot; location=&quot;devel&quot;\/&gt;\r\n    &lt;property name=&quot;live&quot; location=&quot;live&quot;\/&gt;\r\n    &lt;property name=&quot;backup&quot; location=&quot;backup&quot;\/&gt;\r\n\r\n    &lt;property name=&quot;db_host&quot; value=&quot;localhost&quot;\/&gt;\r\n    &lt;property name=&quot;db&quot; value=&quot;databasename&quot;\/&gt;\r\n    &lt;property name=&quot;db_user&quot; value=&quot;databaseuser&quot;\/&gt;\r\n    &lt;property name=&quot;db_pass&quot; value=&quot;databasepassword&quot;\/&gt;\r\n\r\n    &lt;target name=&quot;build&quot;&gt;\r\n        &lt;!-- create the timestamp --&gt;\r\n        &lt;tstamp\/&gt;\r\n\r\n        &lt;!-- create the backup dir --&gt;\r\n        &lt;mkdir dir=&quot;${backup}_${DSTAMP}&quot;\/&gt;\r\n\r\n        &lt;!-- dumb db to backup dir --&gt;\r\n        &lt;echo message=&quot;create mysqldump&quot;\/&gt;\r\n        &lt;exec executable=&quot;mysqldump&quot; output=&quot;${backup}_${DSTAMP}\/dump_${db}.sql&quot;&gt;\r\n            &lt;arg value=&quot;${db}&quot;\/&gt;\r\n            &lt;arg value=&quot;-u${db_user}&quot;\/&gt;\r\n            &lt;arg value=&quot;-p${db_pass}&quot;\/&gt;\r\n        &lt;\/exec&gt;\r\n\r\n        &lt;!-- copy current live dir to backup dir --&gt;\r\n        &lt;copy todir=&quot;${backup}_${DSTAMP}&quot;&gt;\r\n            &lt;fileset dir=&quot;${live}&quot;\/&gt;\r\n        &lt;\/copy&gt;\r\n\r\n        &lt;!-- copy current devel dir to live dir --&gt;\r\n        &lt;copy todir=&quot;${live}&quot;&gt;\r\n            &lt;fileset dir=&quot;${devel}&quot; excludes=&quot;**\/*index.php&quot;\/&gt;&lt;!-- beware overiding main config index.php --&gt;\r\n        &lt;\/copy&gt;\r\n\r\n        &lt;!-- delete cache\/log files --&gt;\r\n        &lt;echo message=&quot;cleanup cache\/logs in backup\/live&quot;\/&gt;\r\n        &lt;delete includeemptydirs=&quot;true&quot;&gt;\r\n            &lt;fileset dir=&quot;${backup}_${DSTAMP}\/application\/cache&quot; includes=&quot;**\/*&quot;\/&gt;\r\n            &lt;fileset dir=&quot;${backup}_${DSTAMP}\/application\/logs&quot; includes=&quot;**\/*&quot;\/&gt;\r\n             &lt;fileset dir=&quot;${live}\/application\/cache&quot; includes=&quot;**\/*&quot;\/&gt;\r\n            &lt;fileset dir=&quot;${live}\/application\/logs&quot; includes=&quot;**\/*&quot;\/&gt;\r\n        &lt;\/delete&gt;\r\n    &lt;\/target&gt;\r\n&lt;\/project&gt;\r\n\r\n<\/pre>\n<p>Dieses Skript wird auf der Kommandozeile von Linux ausgef\u00fchrt.<\/p>\n<p>ANT sucht per default nach einer <strong>build.xml<\/strong> im ausf\u00fchrenden Ordner.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\nuser@server:~\/pages$ ant\r\n\r\nBuildfile: build.xml\r\n\r\nbuild:\r\n    &#x5B;mkdir] Created dir: \/home\/user\/pages\/backup_20091027\r\n     &#x5B;echo] create mysqldump\r\n     &#x5B;copy] Copying 1153 files to \/home\/user\/pages\/backup_20091027\r\n     &#x5B;copy] Copied 261 empty directories to 5 empty directories under \/home\/user\/pages\/backup_20091027\r\n     &#x5B;copy] Copying 50 files to \/home\/user\/pages\/live\r\n     &#x5B;echo] cleanup cache\/logs in backup\/live\r\n\r\nBUILD SUCCESSFUL\r\nTotal time: 27 seconds\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ANT ist ein wunderbares Kommandozeilen-Tool mit dem man Deployment gerade auch von Webapplikationen automatisieren kann. Ich benutze es um Entwicklungsst\u00e4nde in die Stage oder Liveumgebung auszuspielen. Zur Konfiguration des Deploymentprozesses erzeugt man eine build.xml Datei, die alle n\u00f6tigen Anweisungen enth\u00e4lt. Folgende XML Datei erzeugt einen Backup-Ordner und kopiert die aktuelle Live-Applikation dort hinein. Desweiteren erzeugt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78,77,75,76,79],"tags":[647,646,82,80,81,648],"class_list":["post-104","post","type-post","status-publish","format-standard","hentry","category-ant","category-deployment","category-linux","category-shell","category-xml","tag-ant","tag-deployment","tag-development","tag-live","tag-stage","tag-xml"],"_links":{"self":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/comments?post=104"}],"version-history":[{"count":19,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/104\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/104\/revisions\/111"}],"wp:attachment":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/media?parent=104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/categories?post=104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/tags?post=104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}