Crate repo_backup[−][src]
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:
- Query each
Provider
in theConfig
for the available repositories, and - Download each repository to
dest_dir
.
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
pub use config::Config; |
Modules
config |
Configuration for |
Macros
cmd |
A convenient command runner. |
Structs
Driver |
A driver for orchestrating the process of fetching a list of repositories and then downloading each of them. |
GitHub |
An interface to the repositories stored on github. |
GitLab |
A provider which queries the GitLab API. |
Repo |
A repository. |
UpdateFailure |
A wrapper around one or more failures during the updating process. |
Traits
Provider |
A source of repositories. |