Skip to content

Recipes

klm1 edited this page Aug 23, 2016 · 1 revision

Here are some “recipes” for doing common tasks with kiln-local-backup.

Back up one project or group, instead of all repositories

To back up just some of your repositories, use the --limit comnand-line option.

  • If you specify a Project, then all groups and repositories in that project will be backed up.
  • If you specify a Group (Project/Group), then all repositories in that group will be backed up.
  • If you specify a single repository (Project/Group/RepoName), just that repository will be backed up.

Let’s say you have a project called “Microsoft Office”, and under that, a group called “Excel”, and in that group, two repositories, “Mac” and “Windows”. You could back up the entire “Excel” group like this:

$ ./kiln_local_backup.py --limit "Microsoft Office/Excel" /my-backup-directory


Back up to same server without SSL

By default, Kiln uses SSL (https) to backup repositories. For the case where you are running the backup on the same server as the Kiln server, it might make more sense to skip the SSL using the --scheme option and avoid any certificate issues and SSL overhead:

$ ./kiln_local_backup.py --scheme=http /my-backup-directory


Compress the backup into a .zip or .tar.gz archive after backing up

What it does

After completing the backup, this will create a .zip or .tar.gz file containing the entire contents of the backup. You may find this easier to manage if you need to copy the backup to an offsite location or keep an archived copy of it.

Anton Moiseev has created a fork of kiln-local-backup that includes this functionality as a built-in command-line option.

You can find it here: anton-fork.

Linux/Mac OS X Example

./kiln_local_backup.py --quiet ~/my-backup-dir && \ tar czf ~/my-backup.tar.gz -C ~/my-backup-dir .

This backs up your Kiln repositories and, if the backup succeeds, creates a .tar.gz file containing the entire contents of the backup. To make a .tar.bz2 file instead, change tar czf to tar cjf.

Windows Example

C:\> python kiln_local_backup.py D:\my-backup-dir …  
C:\> 7z a -tzip -r D:\my-backup.zip D:\my-backup-dir\*.*

This backs up your Kiln repositories and then uses 7-Zip to compress the entire backup into a .zip file. This assumes you have 7-Zip installed and on your PATH.

You could also use RAR or another tool, but make sure it is zipping the critical .hg or .git subdirectories in each repository. 7-Zip is known to work correctly.

Automation

You can use the Linux/OS X version of this recipe in a cron job. For Windows, you should put the two commands into a .cmd file, which you can run from Scheduled Tasks.