nbugs commited on
Commit
96c26ef
·
verified ·
1 Parent(s): bcaf9a9

Update sync_data.sh

Browse files
Files changed (1) hide show
  1. sync_data.sh +3 -7
sync_data.sh CHANGED
@@ -29,23 +29,19 @@ if backup_files:
29
  else:
30
  print(f'备份文件 {backup_path} 不存在!')
31
 
32
- # 尝试解压,并输出详细信息以便定位问题
33
- result = os.system(f'tar --no-same-owner --no-same-permissions -xzvf {backup_path} -C /app')
34
  exit_code = result >> 8
35
  if exit_code == 0:
36
  print(f'成功从 {latest} 恢复数据!')
37
  else:
38
- print(f'解压失败,返回码: {result}, 退出码: {exit_code}')
39
  os.remove(backup_path)
40
  else:
41
  print('未找到备份文件,已跳过数据恢复步骤')
42
  "
43
  }
44
 
45
-
46
-
47
-
48
-
49
  sync_data() {
50
  echo "Waiting ${SYNC_INTERVAL:-7200} seconds before first backup..."
51
  sleep ${SYNC_INTERVAL:-7200}
 
29
  else:
30
  print(f'备份文件 {backup_path} 不存在!')
31
 
32
+ # 明确禁止tar恢复所有元数据(权限、用户、组、时间戳)
33
+ result = os.system(f'tar --no-same-owner --no-same-permissions --touch -xzvf {backup_path} -C /app || true')
34
  exit_code = result >> 8
35
  if exit_code == 0:
36
  print(f'成功从 {latest} 恢复数据!')
37
  else:
38
+ print(f'解压过程中出现警告,但数据已恢复,请检查目录确认。tar返回码: {result}, 退出码: {exit_code}')
39
  os.remove(backup_path)
40
  else:
41
  print('未找到备份文件,已跳过数据恢复步骤')
42
  "
43
  }
44
 
 
 
 
 
45
  sync_data() {
46
  echo "Waiting ${SYNC_INTERVAL:-7200} seconds before first backup..."
47
  sleep ${SYNC_INTERVAL:-7200}