Update sync_data.sh
Browse files- sync_data.sh +5 -6
sync_data.sh
CHANGED
|
@@ -78,16 +78,15 @@ try:
|
|
| 78 |
if filepath and os.path.exists(filepath):
|
| 79 |
print(f'Found latest backup: {latest_backup}, attempting to restore...')
|
| 80 |
# 删除现有的数据目录
|
| 81 |
-
if
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
fi
|
| 85 |
# 创建数据目录(如果被删除)
|
| 86 |
-
|
| 87 |
|
| 88 |
with tarfile.open(filepath, 'r:gz') as tar:
|
| 89 |
tar.extractall('/opt/cloudreve/data')
|
| 90 |
-
|
| 91 |
|
| 92 |
except Exception as e:
|
| 93 |
echo f'Error downloading backup from HuggingFace Dataset: {e}'
|
|
|
|
| 78 |
if filepath and os.path.exists(filepath):
|
| 79 |
print(f'Found latest backup: {latest_backup}, attempting to restore...')
|
| 80 |
# 删除现有的数据目录
|
| 81 |
+
if os.path.isdir('/opt/cloudreve/data'):
|
| 82 |
+
print("Deleting existing data directory: /opt/cloudreve/data")
|
| 83 |
+
shutil.rmtree('/opt/cloudreve/data')
|
|
|
|
| 84 |
# 创建数据目录(如果被删除)
|
| 85 |
+
os.makedirs('/opt/cloudreve/data', exist_ok=True)
|
| 86 |
|
| 87 |
with tarfile.open(filepath, 'r:gz') as tar:
|
| 88 |
tar.extractall('/opt/cloudreve/data')
|
| 89 |
+
print(f'Successfully restored backup from {latest_backup}')
|
| 90 |
|
| 91 |
except Exception as e:
|
| 92 |
echo f'Error downloading backup from HuggingFace Dataset: {e}'
|