Automatic SVN incremental backup
How to create a simple incremental backup system, that you can restore at any time at a later time?
There are a lot of ways to create automatic incremental backups.
The simplest way is to use a post-commit hook that will automatically generate a backup every time we commit something to the repository.
And then we can always backup those files anywhere we want and we can recreate the SVN repository from those files.
Here is the script that will do that:
#!/bin/sh
PROJECT="project_name"
REPOS="$1"
REV="$2"
REVPAD=$(printf "%05d" "$REV")
FILE="${REVPAD}.svndump"
if [ ! -d "/backup/svn/$PROJECT/incremental/" ]; then
mkdir -p /backup/svn/$PROJECT/incremental/
fi
svnadmin dump "$REPOS" --revision "$REV" --incremental > "/backup/svn/$PROJECT/incremental/${FILE}"
So every time we commit it’s gonna create a dump in the backup directory. And after that we can use any number of tools to sync that directory to any remote server we want to.