File tree 2 files changed +19
-6
lines changed
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 65
65
return Err ( anyhow:: anyhow!( "deplicated backup name in config" ) ) ;
66
66
}
67
67
68
+ // check if name contens `-`
69
+ if config. backup . iter ( ) . any ( |b| b. name . contains ( '-' ) ) {
70
+ return Err ( anyhow:: anyhow!( "backup name can not contain `-`" ) ) ;
71
+ }
72
+
68
73
Ok ( config)
69
74
}
70
75
Original file line number Diff line number Diff line change @@ -98,16 +98,24 @@ async fn backup(b: &Backup, s3_oprator: &Operator) -> Result<()> {
98
98
99
99
// Compress with subprocess
100
100
let mut cmd = Command :: new ( "tar" ) ;
101
- cmd. args ( [
102
- "--zstd" ,
103
- "-cf" ,
101
+
102
+ let mut args = vec ! [
103
+ "--zstd" . to_string( ) ,
104
+ "-cf" . to_string( ) ,
104
105
temp_dest
105
106
. to_str( )
106
- . ok_or ( anyhow ! ( "failed to convert path to string" ) ) ?,
107
+ . ok_or( anyhow!( "failed to convert path to string" ) ) ?
108
+ . to_string( ) ,
109
+ ] ;
110
+ args. extend ( b. exclude . iter ( ) . map ( |e| format ! ( "--exclude={}" , e) ) ) ;
111
+ args. push (
107
112
backup_source
108
113
. to_str ( )
109
- . ok_or ( anyhow ! ( "failed to convert path to string" ) ) ?,
110
- ] )
114
+ . ok_or ( anyhow ! ( "failed to convert path to string" ) ) ?
115
+ . to_string ( ) ,
116
+ ) ;
117
+
118
+ cmd. args ( args)
111
119
. kill_on_drop ( true ) ;
112
120
113
121
cmd. stdin ( Stdio :: piped ( ) ) ;
You can’t perform that action at this time.
0 commit comments