Skip to content
This repository has been archived by the owner on Feb 7, 2021. It is now read-only.

Commit

Permalink
Adding initial backup script
Browse files Browse the repository at this point in the history
  • Loading branch information
szotsaki committed Mar 23, 2016
1 parent 68b25c7 commit 24ac516
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions svn-backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Creates complete SVN dumps of all repositories within $repo_dir to $backup_dir.
# Backup is only made when the repo revision is greater than the one of the previous backup.
#
# Only one backup of a repo is kept.
#
# The script implies that the repository names are "prefix codes", i.e. none of
# their names begin with an other repo name (eg. "test" and "test-2")
#
# Compression is made with XZ (LZMA 2).

set -e

repo_dir="/srv/svn/repositories"
backup_dir="/srv/backup/SVN"

svnadmin="/usr/bin/svnadmin"
svnlook="/usr/bin/svnlook"

for repo in "$repo_dir"/*; do
name=$(basename "$repo")
revision=$($svnlook youngest "$repo")
target="$backup_dir/$name-$revision.xz"
if [ ! -e "$target" ]; then
rm -f "$backup_dir/$name-*.xz"
nice $svnadmin dump --deltas --quiet "$repo" | xz --compress --stdout -9 --extreme > "$target"
fi
done

0 comments on commit 24ac516

Please sign in to comment.