Autoscan, A-Train and Bernard are no longer actively maintained. All projects are considered feature frozen and when compatibility with Google Drive, Plex, Emby, Jellyfin and the -arrs inevitably breaks, no fixes will be provided and such an event will officially mark these projects as end of life. As all three projects have permissible open source licenses, feel free to start a fork and continue development. Ownership of these repositories as well as the Docker images will not be transferred.
Bernard aims to be a correct* synchronisation engine for Google Drive metadata. In particular, Bernard,
- Stores file and folder metadata in a SQLite database.
- Keeps track of the changes made in the previous synchronisation.
*The metadata in the database should be a one-to-one copy of the current state within Google Drive after a synchronisation.
This example uses Tokio, so your Cargo.toml
should look like this:
[dependencies]
bernard = { git = "https://github.com/m-rots/bernard-rs" }
tokio = { version = "1", features = ["full"] }
And then the code:
use bernard::{Account, Bernard, SyncKind};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Read the Service Account JSON Key from a file.
let account = Account::from_file("account.json")?;
// Build Bernard.
let bernard = Bernard::builder("bernard.db", account).build().await?;
// Sync the provided Shared Drive.
// Replace the drive_id with a Shared Drive ID your service account has access to.
match bernard.sync_drive("0A1xxxxxxxxxUk9PVA").await? {
// Do not do anything on a full-sync.
SyncKind::Full => (),
// Print the changes this partial sync fetched.
SyncKind::Partial(changes) => {
let paths = changes.paths().await?;
println!("changed paths: {:#?}", paths);
}
}
// Close Bernard's internal connection pool.
// This is required to clean up the .wal and .shm files on shutdown.
bernard.close().await;
Ok(())
}
To use Bernard, you must create a Service Account and then invite this account (the email address) to one or multiple Shared Drives that you want Bernard to have access to.
The Service Account should at least have Reader
permission.
Last but not least, do not forget to enable the Google Drive API in the Google Cloud Project you created the Service Account in.
- Bernard does not work with My Drive nor Shared with me.
- Bernard's only authentication method is through Service Accounts.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.