snipplrCallback({"id":52290,"title":"jasperserver-backup-script","source":"
#!\/bin\/bash<\/span><\/div><\/li> ############################################################################<\/span><\/div><\/li> # JasperReports Server Backup Script.<\/span><\/div><\/li> # Written by Ernesto Ongaro in April 2011<\/span><\/div><\/li> ############################################################################<\/span><\/div><\/li> # JasperReports is free software: you can redistribute it and\/or modify it<\/span><\/div><\/li> # under the terms of the GNU Lesser General Public License as published by<\/span><\/div><\/li> # the Free Software Foundation, either version 3 of the License, or (at your<\/span><\/div><\/li> # option) any later version.<\/span><\/div><\/li> <\/div><\/li> # This script is distributed in the hope that it will be useful,<\/span><\/div><\/li> # but WITHOUT ANY WARRANTY; without even the implied warranty of<\/span><\/div><\/li> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<\/span><\/div><\/li> # GNU Lesser General Public License for more details.<\/span><\/div><\/li> ############################################################################<\/span><\/div><\/li> # Don't just run this script, make sure to edit the options below!<\/span><\/div><\/li> ############################################################################<\/span><\/div><\/li> #set this if you're using JasperServer 3.7.1 or below<\/span><\/div><\/li> IS_PRE_4<\/span>=false<\/span><\/div><\/li> #Friendly Name for Product<\/span><\/div><\/li> PRODUCT_NAME<\/span>="JR-4.0.1-Pro"<\/span><\/div><\/li> BACKUP_DEST<\/span>="\/home\/ernesto\/Dropbox\/Backups"<\/span><\/div><\/li> FILE_NAME<\/span>="`date +%Y%m%d%H%M`<\/span>.zip"<\/span><\/div><\/li> #Delete old backups after some time<\/span><\/div><\/li> DELETE_OLD<\/span>=true<\/span><\/div><\/li> #How many days to keep<\/span><\/div><\/li> DAYS<\/span>=15<\/span><\/div><\/li> <\/div><\/li> cd<\/span> $(<\/span>dirname<\/span> $0<\/span>)<\/span><\/div><\/li> if<\/span> [<\/span> "$IS_PRE_4<\/span>"<\/span> == "true"<\/span> ]<\/span>; then<\/span><\/div><\/li> \tJS_EXPORT_ARGS<\/span>="--everything --skip-access --output-zip"<\/span><\/div><\/li> \tBUILDOMATIC<\/span>="..\/buildomatic\/default_master.properties"<\/span>\t<\/div><\/li> \t#Check if script is in right place<\/span><\/div><\/li> \tif<\/span> [<\/span> $(<\/span>basename<\/span> $(<\/span>pwd<\/span>)<\/span>)<\/span> !<\/span>= "scripts"<\/span> ]<\/span>; then<\/span><\/div><\/li> \techo<\/span> "This script should live in the <js-install>\/scripts folder for pre 4.0 installations. Exiting."<\/span><\/div><\/li> \texit<\/span> 1<\/span><\/div><\/li> \tfi<\/span><\/div><\/li> else<\/span><\/div><\/li> \t#Then we're working with 4.0+<\/span><\/div><\/li> \tJS_EXPORT_ARGS<\/span>="--everything --output-zip"<\/span><\/div><\/li> \tBUILDOMATIC<\/span>="default_master.properties"<\/span><\/div><\/li> \tif<\/span> [<\/span> $(<\/span>basename<\/span> $(<\/span>pwd<\/span>)<\/span>)<\/span> !<\/span>= "buildomatic"<\/span> ]<\/span>; then<\/span><\/div><\/li> \techo<\/span> "This script should live in the <js-install>\/buildomatic folder for 4.0+ installations. Exiting."<\/span><\/div><\/li> \texit<\/span> 1<\/span><\/div><\/li> \tfi<\/span><\/div><\/li> fi<\/span><\/div><\/li> <\/div><\/li> # Read information from js config file<\/span><\/div><\/li> DB_USER<\/span>=$(<\/span>sed<\/span> '\/^\\#\/d'<\/span> $BUILDOMATIC<\/span> |<\/span> grep<\/span> 'dbUsername'<\/span> |<\/span> tail<\/span> -n<\/span> 1<\/span> |<\/span> cut<\/span> -d<\/span> "="<\/span> -f2-<\/span> |<\/span> sed<\/span> 's\/^[[:space:]]*\/\/;s\/[[:space:]]*$\/\/'<\/span>)<\/span><\/div><\/li> DB_PASS<\/span>=$(<\/span>sed<\/span> '\/^\\#\/d'<\/span> $BUILDOMATIC<\/span> |<\/span> grep<\/span> 'dbPassword'<\/span> |<\/span> tail<\/span> -n<\/span> 1<\/span> |<\/span> cut<\/span> -d<\/span> "="<\/span> -f2-<\/span> |<\/span> sed<\/span> 's\/^[[:space:]]*\/\/;s\/[[:space:]]*$\/\/'<\/span>)<\/span><\/div><\/li> DB_NAME<\/span>=$(<\/span>sed<\/span> '\/^\\#\/d'<\/span> $BUILDOMATIC<\/span> |<\/span> grep<\/span> 'js.dbName'<\/span> |<\/span> tail<\/span> -n<\/span> 1<\/span> |<\/span> cut<\/span> -d<\/span> "="<\/span> -f2-<\/span>