Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "awsbck"
version = "0.2.4"
version = "0.2.5"
edition = "2021"
authors = ["Valentin Bersier <vbersier@gmail.com>"]
license = "MIT OR Apache-2.0"
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Arguments:

Options:
-i, --interval <SECONDS> Specify an interval in seconds to run the backup periodically [env: AWSBCK_INTERVAL=]
-f, --filename <NAME> The name of the archive that will be uploaded to S3, without extension (optional) [env: AWSBCK_FILENAME=]
-r, --region <REGION> The AWS S3 region [env: AWS_REGION=]
-b, --bucket <BUCKET> The AWS S3 bucket name [env: AWS_BUCKET=]
--id <KEY_ID> The AWS S3 access key ID [env: AWS_ACCESS_KEY_ID=]
Expand All @@ -40,6 +41,16 @@ $ awsbck -i 3600 -b my_bucket /my_folder

## Installation

### Prebuilt binaries

Check out [the releases](https://github.com/beeb/awsbck-rs/releases) for prebuilt binaries.

### Cargo

```shell
$ cargo install awsbck
```

### Docker

Coming soon
25 changes: 17 additions & 8 deletions src/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ pub async fn upload_file(archive_path: PathBuf, _temp_dir: TempDir, params: &Par
.load()
.await;
let client = Client::new(&shared_config);
let filename = format!(
"awsbck_{}.tar.gz",
params
.folder
.file_name()
.map(|f| f.to_string_lossy().to_string())
.unwrap_or("backup".to_string())
);
let filename = params
.filename
.clone()
.map(|f| match f {
f if !f.ends_with(".tar.gz") => format!("{f}.tar.gz"),
f => f,
})
.unwrap_or_else(|| {
format!(
"awsbck_{}.tar.gz",
params
.folder
.file_name()
.map(|f| f.to_string_lossy().to_string())
.unwrap_or("backup".to_string())
)
});
let multipart_upload_res: CreateMultipartUploadOutput = client
.create_multipart_upload()
.bucket(&params.aws_bucket)
Expand Down
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ struct Cli {
#[arg(short, long, value_name = "SECONDS", env = "AWSBCK_INTERVAL")]
interval: Option<u64>,

/// The name of the archive that will be uploaded to S3, without extension (optional)
#[arg(short, long, value_name = "NAME", env = "AWSBCK_FILENAME")]
filename: Option<String>,

/// The AWS S3 region
#[arg(
short = 'r',
Expand Down Expand Up @@ -59,6 +63,8 @@ pub struct Params {
pub folder: PathBuf,
/// An optional interval duration in seconds
pub interval: Option<u64>,
/// The name of the archive that will be uploaded to S3 (without extension)
pub filename: Option<String>,
/// The AWS S3 region
pub aws_region: RegionProviderChain,
/// The AWS S3 bucket name
Expand Down Expand Up @@ -100,6 +106,7 @@ pub async fn parse_config() -> Result<Params> {
Ok(Params {
folder,
interval: params.interval,
filename: params.filename,
aws_region,
aws_bucket,
aws_key_id,
Expand Down