Skip to content

Commit

Permalink
fix: backup_worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Apr 4, 2024
1 parent e74d3fe commit 8473d03
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions gc_fs_backup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ edition = "2021"
description = "Backup a compressed tarball of a directory to Google Cloud Storage"
license = "MIT"

[[bin]]
name = "gc_fs_backup_worker"
path = "src/backup_worker.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.81"
clap = "4.5.4"
flate2 = "1.0.28"
google-cloud = "0.2.1"
inotify = "0.10.2"
Expand Down
37 changes: 37 additions & 0 deletions gc_fs_backup/src/backup_worker.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::path::PathBuf;

use clap::Parser;
use gc_fs_backup::GcFsBackupBuilder;

#[derive(Parser)]
#[clap(version = "1.0", author = "Kody Low <[email protected]>")]
struct Cli {
/// Sets the database path to backup
#[clap(long, value_name = "DB_PATH", env = "DB_PATH", required = true)]
db_path: PathBuf,

/// Sets the bucket ID for the backup
#[clap(long, value_name = "BUCKET_ID", env = "BUCKET_ID", required = true)]
bucket_id: String,

/// Sets the credentials for accessing the storage
#[clap(long, value_name = "CREDENTIAL", env = "CREDENTIAL", required = true)]
credential: String,

/// Sets the name for the backup
#[clap(long, value_name = "BACKUP_NAME", env = "BACKUP_NAME")]
backup_name: String,
}

#[tokio::main]
async fn main() {
let cli: Cli = Cli::parse();

let backup = GcFsBackupBuilder::new()
.db_path(cli.db_path.into())
.bucket_id(cli.bucket_id.into())
.credential(cli.credential.into())
.backup_name(cli.backup_name.into())
.build();
backup.backup_directory_contents().await.unwrap();
}

0 comments on commit 8473d03

Please sign in to comment.