flzta commited on
Commit
f4fe845
·
verified ·
1 Parent(s): 0033348

Update sync_data.sh

Browse files
Files changed (1) hide show
  1. sync_data.sh +32 -18
sync_data.sh CHANGED
@@ -94,8 +94,6 @@ try:
94
  repo_type='dataset'
95
  )
96
  print(f'Successfully uploaded $file_name')
97
-
98
- manage_backups(api, repo_id_val)
99
  except Exception as e:
100
  print(f'Error uploading file: {str(e)}')
101
  "
@@ -142,25 +140,41 @@ try:
142
 
143
  if filepath and os.path.exists(filepath):
144
  print(f'Successfully downloaded backup to temporary directory: {filepath}')
145
- echo \"Before restoring backup:\"
146
- ls -l \"$CLOUDREVE_DIR\"
 
147
 
148
  # 删除现有的 Cloudreve 目录和配置文件
149
- rm -rf \"$CLOUDREVE_DIR/cloudreve\"
150
- rm -f \"$CLOUDREVE_DIR/cloudreve.db\"
151
- rm -f \"$CLOUDREVE_DIR/config.ini\"
152
- rm -rf \"$CLOUDREVE_DIR/data\" # 也删除数据目录
153
-
154
- echo \"Deletion complete.\"
155
-
156
- echo \"Extracting backup archive: $filepath to $CLOUDREVE_DIR\"
157
- tar -xzf \"$filepath\" -C \"$CLOUDREVE_DIR\"
158
- echo \"Successfully restored backup from $latest_backup\"
159
-
160
- echo \"After restoring backup:\"
161
- ls -l \"$CLOUDREVE_DIR\"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  else:
163
- echo 'Error during file download.'
164
 
165
  except Exception as e:
166
  print(f'Error downloading backup: {str(e)}')
 
94
  repo_type='dataset'
95
  )
96
  print(f'Successfully uploaded $file_name')
 
 
97
  except Exception as e:
98
  print(f'Error uploading file: {str(e)}')
99
  "
 
140
 
141
  if filepath and os.path.exists(filepath):
142
  print(f'Successfully downloaded backup to temporary directory: {filepath}')
143
+ print(\"Before restoring backup:\")
144
+ import subprocess
145
+ subprocess.run(['ls', '-l', \"$CLOUDREVE_DIR\"], shell=True, check=False)
146
 
147
  # 删除现有的 Cloudreve 目录和配置文件
148
+ import shutil
149
+ cloudreve_path = os.path.join(\"$CLOUDREVE_DIR\", \"cloudreve\")
150
+ cloudreve_db_path = os.path.join(\"$CLOUDREVE_DIR\", \"cloudreve.db\")
151
+ config_ini_path = os.path.join(\"$CLOUDREVE_DIR\", \"config.ini\")
152
+ data_path = os.path.join(\"$CLOUDREVE_DIR\", \"data\")
153
+
154
+ if os.path.exists(cloudreve_path):
155
+ print(f'Deleting: {cloudreve_path}')
156
+ shutil.rmtree(cloudreve_path, ignore_errors=True)
157
+ if os.path.exists(cloudreve_db_path):
158
+ print(f'Deleting: {cloudreve_db_path}')
159
+ os.remove(cloudreve_db_path)
160
+ if os.path.exists(config_ini_path):
161
+ print(f'Deleting: {config_ini_path}')
162
+ os.remove(config_ini_path)
163
+ if os.path.exists(data_path):
164
+ print(f'Deleting: {data_path}')
165
+ shutil.rmtree(data_path, ignore_errors=True)
166
+ print(\"Deletion complete.\")
167
+
168
+ print(f'Extracting backup archive: {filepath} to $CLOUDREVE_DIR')
169
+ import tarfile
170
+ with tarfile.open(filepath, 'r:gz') as tar:
171
+ tar.extractall(\"$CLOUDREVE_DIR\")
172
+ print(f'Successfully restored backup from {latest_backup}')
173
+
174
+ print(\"After restoring backup:\")
175
+ subprocess.run(['ls', '-l', \"$CLOUDREVE_DIR\"], shell=True, check=False)
176
  else:
177
+ print('Error during file download.')
178
 
179
  except Exception as e:
180
  print(f'Error downloading backup: {str(e)}')