/dev/trouble
Eric Roller's Development Blog

Just added a new section to /etc/periodic/monthly/mine.monthly in the attempt to create monthly backups of my subversion repositories, using compressed dump files:

[Update: Now using quoted variable names.] [Update: Now checking "format" file.]

if [ -d /Library/Repositories ]; then
  cd /Library/Repositories
  for i in * ; do
    # Not a subversion repository? Ignore it.
    if [ ! -f "$i/format" ]; then
        continue
    fi
    line="/tmp/monthly-$i.out"
    # File: /Volumes/Backups/Attic/svn-file-2014-01-17.dump.gz
    name="svn-$i-`date +%F`.dump.gz"
    dump="/Volumes/Backups/Attic/$name"
    if [ ! -f "$dump" ]; then
      echo "Dumping subversion repository: $name"
      # Dump into a gzipped file; "Dumped revision n" into temp file.
      { /usr/bin/svnadmin dump "$i" | gzip -c -9 > "$dump"; } >& "$line"
      # Change the user for the dump file.
      chown gollum:gollum "$dump"
      # Only output the last stderr line then delete the file.
      tail -1 "$line"
      rm "$line"
    else
      echo "Warning: Dump already exists: $name"
    fi
  done
else
  echo "Error: Repositories directory not found."
fi

N.B. I also use TrashLater to keep files for only 6 months in the Attic folder.

For /etc/periodic/weekly/mine.weekly I only dump the most recently modified repository since I don't normally work on multiple projects. This is done with a different foreach loop, where we get just one repository file name:

if [ -d /Library/Repositories ]; then
  cd /Library/Repositories
  # List the dir by last modified and get the first entry only.
  for i in `ls -1t | sed '1 q'` ; do
    line="/tmp/weekly-$i.out"
    # [...as above...]
  done
else
  echo "Error: Subversion repositories not found."
fi

Seen errors like this, e.g. upon "svn update" issued on a remote machine when the repository is on a server:

svn: Berkeley DB error for filesystem '.../Repositories/proj/db' while
opening 'nodes' table: Invalid argument
svn: bdb: file nodes (meta pgno = 0) has LSN [95][515282].
svn: bdb: end of log is [95][14597]
svn: bdb: .../Repositories/proj/db/nodes: unexpected file type or
format

Not sure what the main cause is, but it could be a bug with svnserve since it is the one who is running as root. Login with ssh on the server and cd to the directory mentioned in the error:

cd Repositories/proj/db
ls -l
[...]
-rw-r--r--   1 root  goblin   1048576 Aug  4 17:42 log.0000000095
-rw-r--r--   1 root  goblin   1048576 Aug  4 17:52 log.0000000096

Notice that there are files whose owner is root while the other files (not shown) are owned by globlin. We can fix that with chmod:

sudo chown goblin log.000000009*
cd ../..
svnadmin recover proj

Back on the remote machine, try again to run "svn update".