@@ -90,7 +90,8 @@ async fn period_backup(b: &Backup, s3_oprator: &Operator) -> Result<()> {
90
90
91
91
let next_run_date = chrono:: Utc :: now ( ) + chrono:: Duration :: seconds ( b. interval as i64 ) ;
92
92
tracing:: info!(
93
- "The next backup will be run at {}" ,
93
+ "[{}] The next backup will be run at {}" ,
94
+ b. name,
94
95
next_run_date. to_rfc2822( )
95
96
) ;
96
97
@@ -137,13 +138,26 @@ async fn backup(b: &Backup, s3_oprator: &Operator) -> Result<()> {
137
138
138
139
let mut child = cmd. spawn ( ) . expect ( "failed to spawn command" ) ;
139
140
let stderr = child. stderr . take ( ) . expect ( "failed to get child's stderr" ) ;
140
- let mut reader = BufReader :: new ( stderr) . lines ( ) ;
141
- while let Some ( line) = reader . next_line ( ) . await ? {
141
+ let mut stderr_reader = BufReader :: new ( stderr) . lines ( ) ;
142
+ while let Some ( line) = stderr_reader . next_line ( ) . await ? {
142
143
tracing:: warn!( "{}" , line) ;
143
144
}
144
- if !child. wait ( ) . await ?. success ( ) {
145
- return Err ( anyhow ! ( "failed to compress" ) ) ;
146
- } ;
145
+
146
+ let exit_code = child
147
+ . wait ( )
148
+ . await ?
149
+ . code ( )
150
+ . ok_or ( anyhow ! ( "tar is terminated by signal" ) )
151
+ . map_err ( |e| {
152
+ tracing:: error!( "failed to get exit code: {}" , e) ;
153
+ e
154
+ } ) ?;
155
+
156
+ match exit_code {
157
+ // ignore exitcode 1, to fix `tar: file changed as we read it`
158
+ 0 | 1 => { }
159
+ _ => return Err ( anyhow ! ( "failed to compress" ) ) ,
160
+ }
147
161
148
162
// Calculate blake3 hash
149
163
let temp_dest_clone = temp_dest. clone ( ) ;
0 commit comments