vilasm commited on
Commit
745e0d5
·
verified ·
1 Parent(s): 22fb791

Create start.sh

Browse files
Files changed (1) hide show
  1. start.sh +43 -0
start.sh ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Configuration from your images
4
+ REPO_ID="your-username/your-dataset"
5
+ HF_TOKEN="your-hf-token"
6
+
7
+ echo "---- System Starting ----"
8
+
9
+ echo "Restoring files from $REPO_ID..."
10
+ huggingface-cli download $REPO_ID \
11
+ --local-dir /home/user/storage \
12
+ --repo-type dataset \
13
+ --token $HF_TOKEN
14
+
15
+ cat <<EOF > /home/user/auto_backup.sh
16
+ #!/bin/bash
17
+ while true
18
+ do
19
+ sleep 300
20
+ echo "Backing up data to Hugging Face..."
21
+ huggingface-cli upload $REPO_ID /home/user/storage \
22
+ --repo-type dataset \
23
+ --token $HF_TOKEN
24
+ done
25
+ EOF
26
+
27
+ chmod +x /home/user/auto_backup.sh
28
+ /home/user/auto_backup.sh &
29
+
30
+ cat <<EOF > /home/user/final_backup.sh
31
+ #!/bin/bash
32
+ sleep 172200
33
+ echo "Hugging Face is about to restart soon. Taking final backup..."
34
+ huggingface-cli upload $REPO_ID /home/user/storage \
35
+ --repo-type dataset \
36
+ --token $HF_TOKEN
37
+ EOF
38
+
39
+ chmod +x /home/user/final_backup.sh
40
+ /home/user/final_backup.sh &
41
+
42
+ echo "--- System is Ready. Access via Web Terminal ---"
43
+ ttyd -p 7860 -W bash