Config Subversion

From KdjWiki

Jump to: navigation, search

NOTE: This is using Gentoo - so modify the commands as necessary if other distro used.

Contents

Initial Setup

Get Subversion

  $ sudo emerge subversion

Prepare Repository

  $ sudo mkdir /var/svn

Secure Repository

  $ sudo chown -R root:apache /var/svn/
  $ sudo chmod -R 750 /var/svn/

Configure SVN Server

  $ cd /etc/conf.d
  $ sudo nano -w svnserve

and change (to be verifyed re security):

  SVNSERVE_USER="root"    # was "apache"

Start (and auto-start) the server

  $ sudo /etc/init.d/svnserve start
  $ sudo rc-update add svnserve default

Configure Apache (optional)

  $ cd /etc/conf.d
  $ sudo nano -w apache2

and and -D DAV and -D SVN to opts:

  APACHE2_OPTS="-D SSL -D PHP4 -D PROXY -D DAV -D SVN"

Create password file:

  $ sudo mkdir /var/svn/conf/
  $ sudo htpasswd2 -m -c /var/svn/conf/svnusers USERNAME

Restart apache:

  $ sudo /etc/init.d/apache2 restart

Create Repository

  $ sudo svnadmin create /var/svn/config

Create state folders

  $ sudo svn mkdir file:///var/svn/config/current/ -m "Creating current directory"
  $ sudo svn mkdir file:///var/svn/config/snapshots/ -m "Creating snapshots directory"

Track /etc directory

  $ sudo svn checkout file:///var/svn/config/current/ /etc

Verify /etc

  $ cd /etc
  $ sudo svn status

you should see a listing such as:

   ? nanorc
   ? hotplug
   ? cron.d
   ...
   ? bash
   ? proftpd

The question marks indicate the files are not in the repository, so you should add them:

  $ sudo svn add *
  $ sudo svn commit -m "Initial addition of files"

Create Initial Snapshot

  $ sudo cp file:///var/svn/config/current file:///var/svn/config/snapshots/1.0


Maintenance

Check for added/deleted files:

  $ sudo svn status /etc

Any new or missing files will have a bang (!)

Add new files to repository:

  $ cd /etc
  $ sudo svn add {filename}
  $ sudo svn commit -m "New file added"

Delete removed files from repository:

  $ cd /etc
  $ sudo svn delete{filename}
  $ sudo svn commit -m "Removed file"

Add new files to /etc (and repository):

Assume you want to add the file ./myfile.conf to /etc:

  $ sudo svn cp myfile.conf /etc/myfile.conf
  $ sudo svn commit -m "New file added"

Viewing changes

  $ sudo svn log /etc

or

  $ sudo svn log /etc --verbose

Create Snapshot

NOTE: Ensure all changes have been committed first

  $ sudo cp file:///var/svn/config/current file:///var/svn/config/snapshots/{my snapshot name}

Comparing snapshots

  $ sudo svn diff file:///var/svn/config/snapshots/{snapshot-a} file:///var/svn/config/snapshots/{snapshot-b}

or to compare the current:

  $ sudo svn diff file:///var/svn/config/snapshots/{snapshot} file:///var/svn/config/current

Restoring from a snapshot

  $ cd /etc
  $ sudo svn switch file:///var/svn/config/snapshots/{snapshot}
Personal tools