Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good and simple way to backup an SVN repo to an FTP server?

Tags:

svn

backup

I'd like to make a backup of my SVN repo using tar and ftp from a cronjob once a day. This is quite easy, but I would like to make sure there's no commit etc. running while the backup is made. While there are times of the day / night where this is highly unlikely, but I'd rather not rely on that, because if I'm already up at night in some crunch, the last thing I need is my SVN or my backups getting messed up.

I'm looking for some very simple but effective safeguard. It's OK if SVN clients get an error while the backup is running (it won't take that long). Should I use

  • something on the filesystem level
  • some SVN hook script
  • something else entirely

I started posting this over at serverfault, but then decided that it is slightly closer to programming than to sysadmin, especially if hooks are involved. Feel free to move it if you think otherwise.

like image 321
Hanno Fietz Avatar asked Dec 01 '25 09:12

Hanno Fietz


1 Answers

The theoretical way of doing a backup safely is to use the svnadmin hotcopy command (more details here). It basically does a copy of one repository (not a dump, a copy), taking care to block all the operations during that time.

This operation is quite fast, so I shouldn't think any client would have an error, they may experience some delay though (depending on the server load and so on).

You can find an example of script on the Apache subversion project website.

If you do a dump, besides the huge time it takes, you won't be sure it will done in an atomic way. Dumps are useful to

  • make sure you can migrate from one version to the next - think long-term backups. For example if your server is upgraded from version 1.4 to 1.5, or to 1.6, it's interesting to make a dump then a load of your repositories to take full advantage of the improvements. In some more drastic upgrades it's a necessity because the repository format changes too much.
  • filter files out, or merge repositories, those are more complex operations, out of topic here.

Before opting for a dump, should you prefer that anyway, I encourage you to do the operation manually before, to make sure it is not too long. Make sure also to compress those files, which are much bigger than a repository (hotcopy) - the latter is very well compressed.

like image 172
RedGlyph Avatar answered Dec 04 '25 21:12

RedGlyph