feat: added backup cli command
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/clippy Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details

incremental-backups
Jef Roosens 2023-06-16 17:23:36 +02:00
parent 27d7e681c3
commit 5275356353
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 29 additions and 1 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://git.rustybever.be/Chewing_Bever/alex/src/branch/dev)
### Added
* Added `backup` CLI command
### Changed
* Running the server now uses the `run` CLI subcommand

View File

@ -50,6 +50,9 @@ pub struct Cli {
pub enum Commands {
/// Run the server
Run(RunArgs),
/// Create a new backup of the server. This command should only be used when the server is not
/// running.
Backup(BackupArgs),
}
#[derive(Args)]
@ -89,3 +92,12 @@ pub struct RunArgs {
#[arg(short, long, default_value_t = false)]
pub dry: bool,
}
#[derive(Args)]
pub struct BackupArgs {
/// Type of server
pub type_: ServerType,
/// Version string for the server, e.g. 1.19.4-545
#[arg(env = "ALEX_SERVER_VERSION")]
pub server_version: String,
}

View File

@ -4,7 +4,7 @@ mod signals;
mod stdin;
use clap::Parser;
use cli::{Cli, Commands, RunArgs};
use cli::{BackupArgs, Cli, Commands, RunArgs};
use std::io;
use std::sync::{Arc, Mutex};
@ -57,10 +57,22 @@ fn command_run(cli: &Cli, args: &RunArgs) -> io::Result<()> {
signals::handle_signals(&mut signals, counter)
}
fn commands_backup(cli: &Cli, _args: &BackupArgs) -> io::Result<()> {
let mut manager = server::BackupManager::open(
cli.backup.clone(),
cli.config.clone(),
cli.world.clone(),
cli.max_backups,
)?;
manager.create_backup()
}
fn main() -> io::Result<()> {
let cli = Cli::parse();
match &cli.command {
Commands::Run(args) => command_run(&cli, args),
Commands::Backup(args) => commands_backup(&cli, args),
}
}