Unifying Sync and Backup - Part 2
This is a follow up to the first part, which outlines some of the motivation and justification behind using a Subversion monorepo to sync all files across different computers. As a companion, I thought I would go through some of the technical details of setting it up. This is not a tutorial, but with the appropriate changes to the parts which are specific to my set-up, such as file paths, it could be followed as though it was one.
For my current setup I am running (Ubuntu Server)[https://ubuntu.com/download/server], hence the use of apt
below, and other Ubuntu specific things. These steps can be completed on a fresh install.
The first step was to install Subversion and Apache.
sudo apt-get update
sudo apt-get install subversion apache2 libapache2-mod-svn
Then to create a folder to hold the repositories.
mkdir /home/aaron/subversion
The configuration file for Apache which will contain the Subversion server's settings can be found at /etc/apache2/mods-available/dav_svn.conf
, and for my setup, I added the following to it.
<Location /svn>
DAV svn
SVNParentPath /home/aaron/subversion
AuthType Basic
AuthName "svn-repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
LimitXMLRequestBody 8000000
LimitRequestBody 0
</Location>
Then I restarted the server by running
sudo /etc/init.d/apache2 restart
and set the appropriate permissions with
sudo chown -R www-data:www-data /home/aaron/subversion
Finally the user can be created, here by the name of aaron
, by running
sudo htpasswd -c /etc/apache2/dav_svn.passwd aaron
which gets stored in the AuthUserFile
specified within the configuration file from earlier.
With the server setup, a new repository, with the name repo
can be created by first creating the folder
mkdir /home/aaron/subversion/repo
and then telling Subversion to treat this as a repository, and setting the appropriate permissions
svnadmin create /home/aaron/subversion/repo
sudo chown -R www-data:www-data /home/aaron/subversion/repo
Before moving to the client computer, it is also important to grap the IP address with
hostname -I
Now, with the IP address in hand, checking out the repository is as simple as running
svn checkout http://<ip>/svn/repo
For my setup, I also do a sync to Backblaze by running
b2 sync --delete --replace-newer /home/aaron/subversion/ b2://<backblaze-bucket>/
where b2 is the backblaze command line tool, and <backblaze-bucket>
is replaced with the unique name of the bucket I am sending to. This does a one way sync, meaning it forces the bucket to exactly match the local file.