fdfe4dd2868e49ac38b0b99a80c4af322b882cec
wiki/info/landscape/creating-ec2-image-for-webserver-from-scratch.md
| ... | ... | @@ -99,74 +99,6 @@ su -l -c '/usr/share/awstats/tools/awstats_updateall.pl now -configdir=" |
| 99 | 99 | exit 0 |
| 100 | 100 | ``` |
| 101 | 101 | * Follow the [mail setup](https://wiki.sapsailing.com/wiki/info/landscape/mail-relaying#setup-central-mail-server-instance-webserver) instructions |
| 102 | -* Install the backup.sh script with the following contents: |
|
| 103 | -``` |
|
| 104 | -#!/bin/sh |
|
| 105 | - |
|
| 106 | -# This is a template for creating backup of data and persist them |
|
| 107 | -# to a central backup server. Make sure to adapt this script to your needs. |
|
| 108 | -# |
|
| 109 | -# Maintainer: simon.marcel.pamies@sap.com |
|
| 110 | - |
|
| 111 | -export HOME=/root |
|
| 112 | - |
|
| 113 | -# Directories to backup |
|
| 114 | -BACKUP_DIRECTORIES="/etc /home/trac/git /home/trac/mailinglists /home/trac/maven-repositories /home/trac/p2-repositories /home/trac/releases /home/trac/sapsailing_layouts.git /var/www/static /home/trac/crontab /home/scores /var/log/old" |
|
| 115 | - |
|
| 116 | -# Prefix for backup - set that to the hostname of your server |
|
| 117 | -# Make sure to change this! |
|
| 118 | -PREFIX="webserver" |
|
| 119 | - |
|
| 120 | -# Directory for temporary files |
|
| 121 | -TARGET_DIR=/tmp |
|
| 122 | - |
|
| 123 | -# Configuration for external backup server - needs a ssh key |
|
| 124 | -BACKUP_SERVER="backup@172.31.25.136" |
|
| 125 | - |
|
| 126 | -# Set date for this backup - this makes it possible to compare |
|
| 127 | -# files from different branches |
|
| 128 | -BACKUP_DATE=`date +%s` |
|
| 129 | - |
|
| 130 | -# Aliases |
|
| 131 | -BUP_CMD="/opt/bup/bup" |
|
| 132 | -BUP_ADDITIONAL="-r $BACKUP_SERVER:/home/backup/$PREFIX" |
|
| 133 | -BUP_IGNORES='--exclude-rx=/war/$ --exclude-rx=/cache/unique-ips-per-referrer/stats/' |
|
| 134 | -BUP_CMD_INDEX="$BUP_CMD index $BUP_IGNORES" |
|
| 135 | -BUP_CMD_SAVE="$BUP_CMD save --date=$BACKUP_DATE $BUP_ADDITIONAL" |
|
| 136 | - |
|
| 137 | -PARAM=$@ |
|
| 138 | - |
|
| 139 | -# Make sure to init remote repository |
|
| 140 | -$BUP_CMD init |
|
| 141 | -ssh $BACKUP_SERVER "/opt/bup/bup init -r /home/backup/$PREFIX" |
|
| 142 | - |
|
| 143 | -# Backup general directories |
|
| 144 | -for OTHER_DIR in $BACKUP_DIRECTORIES; do |
|
| 145 | - NORMALIZED_DIR_NAME=${OTHER_DIR//\//-} |
|
| 146 | - $BUP_CMD_INDEX $OTHER_DIR |
|
| 147 | - $BUP_CMD_SAVE -n dir$NORMALIZED_DIR_NAME $OTHER_DIR |
|
| 148 | - # no need to remove any backup files here |
|
| 149 | -done |
|
| 150 | -``` |
|
| 151 | -* Register the backup script as a cron job by establishing the following `/etc/crontab` file: |
|
| 152 | -``` |
|
| 153 | -SHELL=/bin/bash |
|
| 154 | -PATH=/sbin:/bin:/usr/sbin:/usr/bin |
|
| 155 | -MAILTO=simon.marcel.pamies@sap.com |
|
| 156 | -HOME=/ |
|
| 157 | - |
|
| 158 | -# For details see man 4 crontabs |
|
| 159 | - |
|
| 160 | -# Example of job definition: |
|
| 161 | -# .---------------- minute (0 - 59) |
|
| 162 | -# | .------------- hour (0 - 23) |
|
| 163 | -# | | .---------- day of month (1 - 31) |
|
| 164 | -# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... |
|
| 165 | -# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat |
|
| 166 | -# | | | | | |
|
| 167 | -# * * * * * user-name command to be executed |
|
| 168 | -0 22 * * * root /opt/backup.sh |
|
| 169 | -``` |
|
| 170 | 102 | * Install Wordpress |
| 171 | 103 | * Install gollum Wiki |
| 172 | 104 | * Copy git contents of ssh://trac@sapsailing.com/home/trac/git to /home/trac/git |