Skip to content

Commit 65ad3c4

Browse files
authored
Merge pull request #8 from beeb/option-filename
v0.2.5
2 parents 81f2447 + 26b5cfe commit 65ad3c4

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "awsbck"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
edition = "2021"
55
authors = ["Valentin Bersier <[email protected]>"]
66
license = "MIT OR Apache-2.0"

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Arguments:
1919
2020
Options:
2121
-i, --interval <SECONDS> Specify an interval in seconds to run the backup periodically [env: AWSBCK_INTERVAL=]
22+
-f, --filename <NAME> The name of the archive that will be uploaded to S3, without extension (optional) [env: AWSBCK_FILENAME=]
2223
-r, --region <REGION> The AWS S3 region [env: AWS_REGION=]
2324
-b, --bucket <BUCKET> The AWS S3 bucket name [env: AWS_BUCKET=]
2425
--id <KEY_ID> The AWS S3 access key ID [env: AWS_ACCESS_KEY_ID=]
@@ -40,6 +41,16 @@ $ awsbck -i 3600 -b my_bucket /my_folder
4041

4142
## Installation
4243

44+
### Prebuilt binaries
45+
46+
Check out [the releases](https://github.com/beeb/awsbck-rs/releases) for prebuilt binaries.
47+
48+
### Cargo
49+
4350
```shell
4451
$ cargo install awsbck
4552
```
53+
54+
### Docker
55+
56+
Coming soon

src/aws.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@ pub async fn upload_file(archive_path: PathBuf, _temp_dir: TempDir, params: &Par
2424
.load()
2525
.await;
2626
let client = Client::new(&shared_config);
27-
let filename = format!(
28-
"awsbck_{}.tar.gz",
29-
params
30-
.folder
31-
.file_name()
32-
.map(|f| f.to_string_lossy().to_string())
33-
.unwrap_or("backup".to_string())
34-
);
27+
let filename = params
28+
.filename
29+
.clone()
30+
.map(|f| match f {
31+
f if !f.ends_with(".tar.gz") => format!("{f}.tar.gz"),
32+
f => f,
33+
})
34+
.unwrap_or_else(|| {
35+
format!(
36+
"awsbck_{}.tar.gz",
37+
params
38+
.folder
39+
.file_name()
40+
.map(|f| f.to_string_lossy().to_string())
41+
.unwrap_or("backup".to_string())
42+
)
43+
});
3544
let multipart_upload_res: CreateMultipartUploadOutput = client
3645
.create_multipart_upload()
3746
.bucket(&params.aws_bucket)

src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ struct Cli {
2121
#[arg(short, long, value_name = "SECONDS", env = "AWSBCK_INTERVAL")]
2222
interval: Option<u64>,
2323

24+
/// The name of the archive that will be uploaded to S3, without extension (optional)
25+
#[arg(short, long, value_name = "NAME", env = "AWSBCK_FILENAME")]
26+
filename: Option<String>,
27+
2428
/// The AWS S3 region
2529
#[arg(
2630
short = 'r',
@@ -59,6 +63,8 @@ pub struct Params {
5963
pub folder: PathBuf,
6064
/// An optional interval duration in seconds
6165
pub interval: Option<u64>,
66+
/// The name of the archive that will be uploaded to S3 (without extension)
67+
pub filename: Option<String>,
6268
/// The AWS S3 region
6369
pub aws_region: RegionProviderChain,
6470
/// The AWS S3 bucket name
@@ -100,6 +106,7 @@ pub async fn parse_config() -> Result<Params> {
100106
Ok(Params {
101107
folder,
102108
interval: params.interval,
109+
filename: params.filename,
103110
aws_region,
104111
aws_bucket,
105112
aws_key_id,

0 commit comments

Comments
 (0)