Crate repo_backup

Source
Expand description

A small utility for making a local copy of all your projects from a variety of various sources.

Sources currently supported:

§Configuration

Configuration is done via a repo-backup.toml file. By default the repo-backup program will look for this in your home directory (as ~/.repo-backup.toml), but this can be overridden via the command line.

The configuration file looks something like this:

[general]
dest-dir = "/srv"

[github]
api-key = "your API key"
owned = true
starred = false

[gitlab]
api-key = "your API key"
host = "gitlab.com"
organisations = true
owned = true

The only required table is general, with the others used to enable and configure the corresponding Provider.

§Examples

This crate is designed to be really easy to use as both an executable, and a library.

The Driver will:

use repo_backup::{Config, Driver};

let cfg = Config::from_file("/path/to/repo-backup.toml")?;
let driver = Driver::with_config(cfg);

driver.run()?;

Or if you want control over the list fetching and download process (e.g. to add a couple extra git repos to the list or use your own Provider):

use repo_backup::{Config, Driver, Repo, Provider};

struct MyCustomProvider;

impl Provider for MyCustomProvider {
    fn name(&self) -> &str {
        "custom-provider"
    }

    fn repositories(&self) -> Result<Vec<Repo>,  Error> {
        unimplemented!()
    }
}

let cfg = Config::from_file("/path/to/repo-backup.toml")?;
let driver = Driver::with_config(cfg);

let providers: Vec<Box<Provider>> = vec![Box::new(MyCustomProvider)];
let mut repos = driver.get_repos_from_providers(&providers)?;

let my_repo = Repo {
    name: String::from("My Repo"),
    owner: String::from("Michael-F-Bryan"),
    provider: String::from("custom"),
    url: String::from("http://my.git.server/Michael-F-Bryan/my_repo"),
};
repos.push(my_repo);

driver.update_repos(&repos)?;

Re-exports§

Modules§

  • Configuration for repo-backup.

Macros§

  • A convenient command runner.

Structs§

  • A driver for orchestrating the process of fetching a list of repositories and then downloading each of them.
  • An interface to the repositories stored on github.
  • A provider which queries the GitLab API.
  • A repository.
  • A wrapper around one or more failures during the updating process.

Traits§