Skip to content

Commit 17c8098

Browse files
committed
SSL/plain configurable, backup script for repositories
1 parent 5bc41f2 commit 17c8098

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ RUN set -eux; \
181181
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /usr/local/apache2/conf/server.key; \
182182
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /usr/local/apache2/conf/server.crt
183183

184-
COPY httpd-foreground /usr/local/bin/
184+
COPY scripts/*.sh /usr/local/bin/
185185
COPY httpd-conf/httpd.conf $HTTPD_PREFIX/conf/
186186
COPY svn-conf/* /svn/config/
187187

188188
EXPOSE 80 443
189-
CMD ["httpd-foreground"]
189+
CMD ["httpd-foreground.sh"]

scripts/backup-svn-repos.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
#
3+
# Backup Subversion repositories. The script performs full dumps, no hot backups or
4+
# incremental backups. It keeps the most recent backups for each repository and only
5+
# performs a dump if there has been a new checkin since the last time.
6+
#
7+
# Usage: backup-svn-repos.sh svn-base-dir backup-dir backups-to-keep
8+
#
9+
set -e
10+
11+
REPO_BASE_DIR=${1:-/svn/repos}
12+
BACKUP_DIR=${2:-/svn/backup}
13+
BACKUPS_TO_KEEP=${3:-4}
14+
CURRENT_DATE=`date +"%Y%m%d"`
15+
16+
for repo in ${REPO_BASE_DIR}/*; do
17+
repo_name=`basename $repo`
18+
repo_revision=`svnlook youngest $repo`
19+
20+
if stat -t ${BACKUP_DIR}/${repo_name}/${repo_name}-*-${repo_revision}.txt.bz2 >/dev/null 2>&1; then
21+
echo Skipping backup of ${repo_name}, revision ${repo_revision} already backed up
22+
else
23+
echo Backing up ${repo_name} with revision ${repo_revision}...
24+
mkdir -p ${BACKUP_DIR}/${repo_name}
25+
base_name=${BACKUP_DIR}/${repo_name}/${repo_name}-${CURRENT_DATE}-${repo_revision}
26+
svnadmin dump --deltas --quiet "$repo" | \
27+
bzip2 > ${base_name}.tmp
28+
mv ${base_name}.tmp ${base_name}.txt.bz2
29+
fi
30+
31+
find ${BACKUP_DIR}/${repo_name} -name ${repo_name}-\*.txt.bz2 \
32+
| sort | head -n -${BACKUPS_TO_KEEP} \
33+
| xargs --no-run-if-empty rm -f
34+
done

0 commit comments

Comments
 (0)